1wearandtearRather than hard-coding the path to where the .PSD1 file resides, or even where the AdminConsole folder is sitting, grab it from the registry…

$pth = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\SMS\Setup" | 
  Select -ExpandProperty "UI Installation Directory"

$psd = "$pth\bin\ConfigurationManager.psd1"

if (!(Test-Path $psd)) {
  Write-Host "your shit is wack. what a tragedy."
else {
  if (Get-Module ConfigurationManager) {
    Write-Host "module is already loaded."
  else {
    Write-Host "loading ConfigMgr PS module..."
    Import-Module $psd
$SiteCode = Get-PSDrive -PSProvider CMSite
cd "$($SiteCode):"
Get-CMAdministrativeUser | Select -ExpandProperty LogonName

The lower-half of that previous example could probably be done a dozen different (better) ways, but hopefully the upper-half (magenta text) helps.  The very bottom-half is just fluff, but whatever.  Back to exam studying…

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s