Я пытаюсь написать скрипт на сервере Windows 2008 R2, чтобы изменить содержимое файла HTM (Statuspage.htm) с «allow_connections = yes» на «allow_connections = no».Я получаю следующую ошибку:
Get-Process : A positional parameter cannot be found that accepts argument
'permit_connections=no '.
At line:1 char:1
+ PS C:\> ((Get-Content -path D:\inetpub\wwwroot\statuspage.htm -Raw) - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand
Get-Process : A positional parameter cannot be found that accepts argument
'Get-Content'.
At line:2 char:1
+ PS C:\> Get-Content -Path (D:\inetpub\wwwroot\statuspage.htm)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand
Вот мой сценарий:
PS C:\> ((Get-Content -Path D:\inetpub\wwwroot\statuspage.htm -Raw) -replace 'permit_connections=yes','permit_connections=no') | Set-Content -Path D:\inetpub\wwwroot\statuspage.htm
PS C:\> Get-Content -path D:\inetpub\wwwroot\statuspage.htm