Update Environment Tab in AD with Powershell

This code will go through the AD and find any users who have the tick boxes,

“Connect client drives at logon”
“Connect client printers at logon”
“Default to main client printer”

Unticked and set them to ticked on.

The value may not exist on every account if the settings have not been change so there will be errors for those accounts but these accounts will show these values as ticked on if checked manually.

Get-ADUser -Filter * -SearchBase “OU=Users,DC=Contoso,DC=Com” | Foreach {
$User = [adsi](“LDAP://” + $_.distinguishedname)
Write-Host $_.distinguishedname
If ($User.InvokeGet(“ConnectClientDrivesAtLogon”) -eq 0)
{Write-Host “Changing ConnectClientDrivesAtLogon for $($_.distinguishedname)”

If ($User.InvokeGet(“ConnectClientPrintersAtLogon”) -eq 0)
{Write-Host “Changing ConnectClientPrintersAtLogon for $($_.distinguishedname)”

If ($User.InvokeGet(“DefaultToMainPrinter”) -eq 0)
{Write-Host “Changing DefaultToMainPrinter for $($_.distinguishedname)”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s