Send-LogoffShutdown_ps1 is an interactive script with the following menu options: Logoff, Force Logoff (NO SAVE), Powerdown, Force Powerdown (NO SAVE), Reboot, Force Reboot (NO SAVE), Ping test, Check for logged on user(s), and Send User(s) Message. Most of the work is done using WMI.
Tag: PowerShell
Is Anybody Using this Workstation?
In a large enterprise you may want to re-deploy unused computers which have been set up but are lightly used or never used. Get-PClastUserLogon_ps1 uses a WMI query to get the last writetime of the user profiles to get this information.
Get Reboot History of Computer from Event Log
Getting the last reboot for a computer is easy and a common task in the administration of servers and workstations. It is a bit more complicated to get the reboot history. I use Get-WinEvent with the filterxml option. Below is the full text of the script, as WordPress has trouble with the text file. The…
Remotely Execute GPRESULT, and Collect Results
A common program for troubleshooting group policies is gpresult. Get-GPResult_ps1. This interactive script uses WMI to allow the administrator to target an existing user on the remote computer, and then to run either gpresult /h or gpresult /v. The results are written to a temporary file on the remote machine, then displayed when the data…
Run Group Policy Update on Remote Computer
Run-GPUpdate_ps1 is a simple script to remotely execute gpupdate /force on a remote computer with this command: invoke-command -ScriptBlock { & cmd /c “C:\windows\system32\gpupdate.exe” /force } -Session $s
Get System Information from a Remote PC
Get-SystemInfo_ps1 is a simple interactive script for remotely running the SystemInfo command remotely: invoke-command -ErrorAction stop -computername $ComputerName -ScriptBlock { systeminfo /fo list } The results are displayed in a text box form.
It’s About Time
I recently went down the rabbit hole working with PowerShell, datetime and time zone calculations. Here are some of the things that I learned: Use [datetimeoffset] instead of [datetime]. [datetimeoffset] has the daylight savings offset as part of the object. Example: [datetimeoffset]$ThisDate = Get-Date -Year 2007 -Month 3 -Day 10 -Hour 0 -Minute 0 -Second…
Test Disk Status
My home media server lost a hard drive earlier this year. I had no idea how long it had been in service, or that it was about to go, despite this data being available from WMI. Test-DiskStatus.ps1 will give you the following information for each drive on the system queried: drive letter, size in GB,…
Getting the Status of a GPO Deployment in an AD Forest
If you are in a large environment, you may be deploying group policies to multiple domains. How can you track the deployment status of the deployment? With Get-GPOdeploymentStatus.ps1, you can enter the name of the GPO, then have all domains queried to discover if it has been installed, who installed it, when it was last…
A Fast Secure Password Generator
This PowerShell one-line generates a reasonably secure password from the characters in the system’s Path. Here I am replacing the space character with the tilde ~ for additional complexity. Get-Enumerator returns each character of the path individually. You can set the password length as the value for the count parameter. $pw = [array](($env:Path).Replace(‘ ‘,’~’).getenumerator() |…