我正在通过AWS SSM发送powershell脚本,如下所示:
ssm_command_result = ssm.send_command(
InstanceIds=listinst,
DocumentName='AWS-RunPowerShellScript',
Comment='logging the', TimeoutSeconds=600,
DocumentVersion='$DEFAULT',
Parameters={
'commands': [r'function Get-SQLserverKey {\
param ($targets = ".")\
$hklm = 2147483650\
$regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\110\Tools\Setup"\
$regValue1 = "DigitalProductId"\
$regValue2 = "PatchLevel"\
For ($i = 24; $i -ge 0; $i--) {\
$k = 0\
For ($j = 14; $j -ge 0; $j--) {\
$k = $k * 256 -bxor $binArray[$j]\
$binArray[$j] = [math]::truncate($k / 24)\
$k = $k % 24\
}\
$productKey = $charsArray[$k] + $productKey\
If (($i % 5 -eq 0) -and ($i -ne 0)) {\
$productKey = "-" + $productKey\
}\
}\
$win32os = Get-WmiObject Win32_OperatingSystem -computer $target\
$obj = New-Object Object\
$obj | Add-Member Noteproperty Computer -value $target\
$obj | Add-Member Noteproperty OSCaption -value $win32os.Caption\
$obj | Add-Member Noteproperty OSArch -value $win32os.OSArchitecture\
$obj | Add-Member Noteproperty SQLver -value $SQLver\
$obj | Add-Member Noteproperty SQLedition -value $SQLedition\
$obj | Add-Member Noteproperty ProductKey -value $productkey\
$obj\
}\
}\
Get-SQLserverKey'
]
})
powershell将返回以下错误:
At C:\\ProgramData\\Amazon\\SSM\\InstanceData\\i-03f470cd998dd89ee\\document\\orchestr\r\nation\\0cff4b86-c635-4b6f-a293-1f3fbdc23e1b\\awsrunPowerShellScript\\0.awsrunPower\r\nShellScript\\_script.ps1:4 char:111\r\n+ ... 10\\Tools\\Setup"\\\r\n+ ~\r\nUnexpected token \'\\\' in expression or statement.\r\nAt C:\\ProgramData\\Amazon\\SSM\\InstanceData\\i-03f470cd998dd89ee\\document\\orchestr\r\nation\\0cff4b86-c635-4b6f-a293-1f3fbdc23e1b\\awsrunPowerShellScript\\0.awsrunPower\r\nShellScript\\_script.ps1:5 char:73\r\n+ $regValue1 = "DigitalProductId"\\\r\n+ ~\r\nUnexpected token \'\\\' in expression or statement.
我已经删除了所有可能的退格,但都是徒劳的。谢谢你的建议。谢谢 问候
目前没有回答
相关问题 更多 >
编程相关推荐