Recently I have tried migrate all my scripts and code to powershell. When we looked to migrate some tasks and Custom Inventory to powershell we had some unexpected issues. These scripts work perfectly on the local machine and even return the custom inventory data back to the server but when run through a task the following errors come back.
The string starting:
At C:\Windows\TEMP\AltirisScript07776FE01A249E11EDA.ps1:95 char:99
+ $members = $Group.psbase.invoke("Members") | {$_.GetType().Invoke
Member("Name", 'GetProperty <<<< ', $null, $_, $null)}
is missing the terminator: '.
At C:\Windows\TEMP\AltirisScript07776FE01A249E11EDA.ps1:135 char:3
+ } <<<<
+ CategoryInfo : ParserError: (, $null, $_, $n... happening"
}:String) [], ParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
I can post the whole code if it would help but the part that it does not like seems to be my expanding of the users in the Administrators group.
$Group = $objComputer.psbase.children.find("Administrators")
$members = $Group.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
ForEach($user in $members)
135 is just the end.
Any idea if there is some sort of special formatting or "rules" to follow when using Powershell as a script.