PowerShell Script to Identify Computer Accounts That Have Not Been Used For A While


Working for an IT Company, providing a support service we have to keep on top of day to day admin tasks, one of these tasks is keeping Active Directory in order. This task can become more difficult as time goes by, as I am sure I am not the only one who does not keep AD up to date when removing PC’s and Servers from the domain… below is a handy little PowerShell script that I put together that will output any PC / Server that has not logged on for 60 days or more:

Stop-Transcript | out-null
$ErrorActionPreference = “Continue”
Start-Transcript -path C:\output.txt -append
$maxOldLogonDays = 60
$adsiSearcher = new-object DirectoryServices.DirectorySearcher(“LDAP://rootdse”)
$adsiSearcher.filter = “objectCategory=Computer”
$adsiSearcher.findall() |
Foreach-Object `
“Processing $($_.path)”
$rawLogon = $_.properties.item(“lastlogon”)
$convertedLogOn = [datetime]::FromFileTime([int64]::Parse($rawLogon))
If( ((get-date) – $convertedLogOn).days  -ge $maxOldLogonDays )
     has not logged on for more than  $maxOldLogonDays days”
  } #end if
} #end foreach

All you need to do is copy and paste the above text to a notepad file and save it as a .PS1 (powershell commandlet format)

VMware Changing the thick or thin provisioning of a virtual disk

This article provides steps to change the provisioning of a virtual disk from thick to thin, or from thin to thick. The procedure uses the vSphere Client and vCenter Server to perform this task

To change the provisioning of a virtual machine base disk from thin to thick from the Datastore Browser:

  1. Power off the virtual machine.
  2. In the vSphere Client, select the virtual machine in the inventory.
  3. Click Edit Settings to display the Virtual Machine Properties dialog box.
  4. Click the Hardware tab and select the appropriate hard disk in the Hardware list. The Disk Provisioning section on the right shows the type of your virtual disk, either Thin or Thick.
  5. Click the Summary tab.
  6. Under Resources, double-click the datastore where the virtual machine resides to open the Datastore Browser dialog box.
  7. Click the virtual machine folder to find the virtual disk file you want to convert. The file has the .vmdk extension.
  8. Right-click the VMDK file, and click Inflate. The Inflate option converts the disk to thick provisioned.


  • If the Inflate option is grayed out, this may indicate that the virtual machine is not powered off or that it is not thin provisioned.
  • There should be no snapshots and the conversion is performed on the base disk.

To convert a virtual machine base disk from thick to thin provisioning by changing the datastore and using offline virtual machine migration:

  1. Power off the virtual machine.
  2. Right-click the virtual machine, and click Migrate.
  3. Click Change datastore.
  4. Click Next, and select a datastore that is not the same as the current datastore.
  5. From the dropdown, select the Thin Provision virtual disk format.
  6. Click Next, then Finish.