Powershell calls winapi to read and write INI files,
# Load winapi $ ini = Add-Type-memberDefinition @ "[DllImport (" Kernel32 ")] public static extern long WritePrivateProfileString (string section, string key, string val, string filePath ); [DllImport ("Kernel32")] public static extern int GetPrivateProfileString (string section, string key, string def, StringBuilder retVal, int size, string filePath ); "@-passthru-name MyPrivateProfileString-UsingNamespace System. text # define the configuration $ section = "server" $ filePath = ". \ test. ini "$ key =" ip "$ val =" 192.168.0.1 "$ retVal = New-Object System. text. stringBuilder (32) # generate or modify the configuration file $ null = $ ini: WritePrivateProfileString ($ section, $ key, $ val, $ filePath) # view the configuration file $ null = $ ini: GetPrivateProfileString ($ section, $ key, "", $ retVal, 32, $ filePath) write-Host $ key "=" $ retVal. tostring ()