asked on
$path = "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory"
#Check to see if ActiveDirectory Module already is installed
if (!(Test-Path $path)){
#Importing the Get-ADComputer function from ActiveDirectory Module
Import-Module \\ct01.uscortec.com\sysvol\CT01.uscortec.com\scripts\Spiceworks\ActiveDirectory\ActiveDirectory.psd1
$switch = $True
}
#Setting the local computer name to a variable
$ADCompName = $env:computername
#Querying Active Directory for the Description of the computer name matching the local computer
$ADDesc = Get-ADComputer -Identity "$ADCompName" -Property Description| Select-Object -ExpandProperty Description
#Grabbing the OS object for access to local PC properties
$CompDesc = Get-WmiObject -Class Win32_OperatingSystem -ComputerName "$ADCompName"
#Setting the local PC description to the current AD description
$CompDesc.Description = "$ADDesc"
#Doing the changes
$CompDesc.Put()
When this script launches on some machines (not all) I get this error.