I wrote a script that works perfectly in a powershell runspace but when run in SCOM as a monitor, the Connect-NcController returns a $null value.
I can run under the local system context or under my user credentials context so it is not a search path or anything like that. The only thing I can find is that when SCOM creates the powershell runspace, it has a $host.Version of "7.0.5000.0" instead of "4.0".
the code that works in the 4.0 space but not in the 7.0.5000.0 space is as follows:
$Password=ConvertTo-SecureString -AsPlainText -Force $UserPassword
$Creds=New-Object System.Management.Automation.PSCredential( $UserName,$Password)
$Controller=Connect-NcController -name $ControllerName -credential $Creds
Does anyone know what is different in the SCOM implementation of powershell versus the standard powershell runspace that causes a $null value to be returned. I have the cmdLet in a try/catch but there is no error so the catch portion of the code never executes. I could at least work with an error but I just get back a $null value which I cannot work with.
Our storage team does not have any vested interest in using plug-in for scom since it woudl monitor the whole solution but we have an interest in monitoring the CIFS shares and the volumes for alerting and reporting and thus why I went this route. I can come up with a work-around but was hoping to find a more forthright solution.
Craig