Script deconstruction – Get all AD users’ last logon time

When I was writing my script to get all AD users’ last logon times I was having an issue with changing the date output format. I posted my question and the version of the script I had at the time to the PowerGUI.org forums. I got an excellent suggestion from Jonathan Tyler and was able

Continue reading Script deconstruction – Get all AD users’ last logon time

Powershell script to get all computers last logon time

I wrote a script to get the last time each computer logged into the domain. ##============================================================================== ##============================================================================== ## SCRIPT………: Get-AllComputerLastLogon ## AUTHOR………: Clint McGuire ## EMAIL……….: ## VERSION……..: 1 ## DATE………..: 2011_05_26 ## COPYRIGHT……: 2011, Clint McGuire ## LICENSE……..: ## REQUIREMENTS…: Powershell v2.0, Quest AD Cmdlets ## DESCRIPTION….: Gets all computer accounts’ last logon times

Continue reading Powershell script to get all computers last logon time

Powershell script to get all AD users’ last logon time

I wanted to see when all users in a client’s domain last logged in.

Here is the script I wrote. ##============================================================================== ##============================================================================== ## SCRIPT………: Get-AllUserLastLogon ## AUTHOR………: Clint McGuire ## EMAIL……….: ## VERSION……..: 1 ## DATE………..: 2011_05_26 ## COPYRIGHT……: 2011, Clint McGuire ## LICENSE……..: ## REQUIREMENTS…: Powershell v2.0, Quest AD Cmdlets ## DESCRIPTION….: Gets all

Continue reading Powershell script to get all AD users’ last logon time

Restart BES 4.1.X services with PowerShell

One of my clients was having issues w/ BES after the Exchange server was rebooted. Aaron at work wrote a couple batch files to stop and start the services in the correct order. I’ve re-written the scripts in PowerShell below. I was hoping to use “Get-Service BES*” and piping it to Stop-Service and Start-Service, but

Continue reading Restart BES 4.1.X services with PowerShell

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

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