PowerShell Notes

Hmmm, what if I…? Add -whatif to the end of your script.

Am I sure I want to make this change to all those users/files/mailboxes? Add -confirm to the script and it will prompt for each item it is making a change on.

Must investigate VMware PowerCLI…

Need to look into PowerGUI and PowerPacks.

http://www.runasradio.com/default.aspx?showNum=203

Expand vSphere Datastore

On the SAN – Increase the volume/LUN size (with a couple snapshots taken just to be safe). Rescan the storage adapters. (Hosts & Clusters, Configuration tab, under Hardware select Storage Adapters, click Rescan All…)

Expand vSphere Datastore – Rescan All

 

 

 

 

 

Click OK to start the scan.

Expand vSphere

Continue reading Expand vSphere Datastore

Remote Desktop Server Management via PowerShell

Start the Windows PowerShell command window and switch to RDS context:

Click Start, click All Programs, and then click Administrative Tools. Right-click Windows PowerShell Modules, and then click Run as Administrator. In the PowerShell command window, type the following:  cd RDS:

Use Dir and CD browse through the options to find the settings you need.

Continue reading Remote Desktop Server Management via PowerShell

Windows 7 x64 RDP Issue

A client on mine bought 2 new Dell XPS 8100s running Windows 7 x64. Everything is great except they couldn’t connect to virtual machines running 2008 R2 or 7 with RDP.  After a few seconds the screen would freeze for a few minutes then work for few seconds only to freeze again.

Connecting to XP

Continue reading Windows 7 x64 RDP Issue

Add DHCP Reservations with a Script

It’s time to upgrade DHCP at one of my clients.   They have a lot of address reservations and we are setting up split-zone DHCP so I didn’t want to have to enter all the reservations by hand, twice.

There has to be a way to script this… PowerShell doesn’t manage DHCP, but I can

Continue reading Add DHCP Reservations with a Script

PowerShell for Active Directory

This is where I will be making note of all the commands I use for managing Active Directory with PowerShell.

How to get Last Logon for all user in an OU: Get-ADUser -Filter * -SearchBase “OU=Test,DC=Domain,DC=local” | %{Get-ADUserLastLogon $_} To get all users last logon times check out this script.

What is Get-ADUserLastLogon? Courtesy of

Continue reading PowerShell for Active Directory

PowerShell Profile

I’ve been tinkering with my profile for a little while and think I have it to a point worth archiving.

Almost nothing here is my own scripting, just finding thing other people have done and maybe modifying it a bit. I do have links to the sources.

##============================================================================== ##============================================================================== ## SCRIPT………: Microsoft.PowerShell_profile.ps1 ## AUTHOR………:

Continue reading PowerShell Profile

PowerShell Remoting

I have been playing with Remoting in PowerShell a lot recently.  I don’t have it all figured out, but I’m getting there.

Here are some of my notes.  (Run on Remote/Destination server, unless otherwise specified.)

To have a custom profile when connected to another machine use: Register-PSSessionConfiguration -Name <name> -StartupScript <scriptname> For consistency I use

Continue reading PowerShell Remoting

How to update GAL and OAB from Exchange Management Shell

To quickly update all the Address Lists and the Offline Address Book, run these 3 command in the Exchange Management Shell:

Get-GlobalAddressList | Update-GlobalAddressList

Get-AddressList | Update-AddressList

Get-OfflineAddressBook | Update-OfflineAddressBook

How to hide items from the Address List in Exchange 2007

A client of mine has not been able to hide items from the GAL by using the EMC.

It appears as though AD is not correctly updated because in ADSI Edit the item has showInAddressBook defined, when it should show <not set>.

To resolve the issue all items must be un-hidden then re-hidden using the Exchange Management

Continue reading How to hide items from the Address List in Exchange 2007