Jun 5, 2013

Reminder to check for a Powershell Snapin before adding it.

Long time no post. Well I have not done much SharePointing lately, but all things change. :)

Until that time, I need to post something. Here is a little bit of code you can see everywhere.


# Add Quest AD Management if installed, otherwise break
if (Get-PSSnapin -Registered Quest.ActiveRoles.ADManagement){
if (-not (Get-PSSnapin Quest.ActiveRoles.ADManagement)){
Add-PSSnapin Quest.ActiveRoles.ADManagement
}
}
else{
Write-Error "Quest Active Directory Snapin not installed!!!!"
break;
}
# Import the AD module
if (-not (Get-Module ActiveDirectory)){
    Import-Module ActiveDirectory -Force | out-null
}

No comments:

Post a Comment