System.Exception: The specified snap-in 'SMlets' failed to load with below exception
System.Management.Automation.PSArgumentException: No snap-ins have been registered for Windows PowerShell version 2.
I have created several powershell scripts that run fine with I run them on the server, however, when I package them in the SM Authoring tool, and deploy them (import MP & copy DLLs) they fail to load the SMlets module.
I believe I have beta3 installed. (how do I check?)
This is SCSM 2012 - on all x64 server Windows 2008 R2
I was initially trying to have the module load via the GUI option in the Authoring tool, then i tried to remove that, and add the import and removal directly in the script.
But is keeps faling with that error... I have only installed SMlets on the management server, not the DW... (do I need to?)
Here is a simple script that fails.
$a = (get-module|%{$_.name}) -join " "
if(!$a.Contains("SMLets")){Import-Module SMLets -ErrorVariable err -Force}
$CRClass = get-scsmclass -name System.WorkItem.ChangeRequest$
$CRobj = Get-SCSMObject -Class $CRClass -Filter "ID -eq $CRID"
if ($CRobj.Status.displayname -eq "approved")
{
$i = 0
if ($CRobj.ActualStartDate -ne $null) {$i++}
if ($CRobj.ActualEndDate -ne $null) {$i++}
if ($CRobj.ImplementationResults -ne $null) {$i++}
}
if ($i -eq 3){Set-SCSMObject -SMObject $CRobj -Property status -Value "executed"}
Remove-module smlets -force
Comments: ** Comment from web user: JFadmin **
System.Management.Automation.PSArgumentException: No snap-ins have been registered for Windows PowerShell version 2.
I have created several powershell scripts that run fine with I run them on the server, however, when I package them in the SM Authoring tool, and deploy them (import MP & copy DLLs) they fail to load the SMlets module.
I believe I have beta3 installed. (how do I check?)
This is SCSM 2012 - on all x64 server Windows 2008 R2
I was initially trying to have the module load via the GUI option in the Authoring tool, then i tried to remove that, and add the import and removal directly in the script.
But is keeps faling with that error... I have only installed SMlets on the management server, not the DW... (do I need to?)
Here is a simple script that fails.
$a = (get-module|%{$_.name}) -join " "
if(!$a.Contains("SMLets")){Import-Module SMLets -ErrorVariable err -Force}
$CRClass = get-scsmclass -name System.WorkItem.ChangeRequest$
$CRobj = Get-SCSMObject -Class $CRClass -Filter "ID -eq $CRID"
if ($CRobj.Status.displayname -eq "approved")
{
$i = 0
if ($CRobj.ActualStartDate -ne $null) {$i++}
if ($CRobj.ActualEndDate -ne $null) {$i++}
if ($CRobj.ImplementationResults -ne $null) {$i++}
}
if ($i -eq 3){Set-SCSMObject -SMObject $CRobj -Property status -Value "executed"}
Remove-module smlets -force
Comments: ** Comment from web user: JFadmin **
I was able to fix this by calling the SMlets module with the literal Path.
$a = (get-module|%{$_.name}) -join " "
if(!$a.Contains("SMLets")){Import-Module 'C:\Program Files\Common Files\SMLets\SMLets.psd1' -ErrorVariable err -Force}