Category: PowerShell
-
PowerShell Script to Restart Multiple Computers
Here’s an example of a PowerShell script that can be used to restart multiple computers: Define the list of computers to restart (Parameters) $Computers = @(“Computer1”,“Computer2”,“Computer3”) Loop through each computer and restart it foreach ($Computer in $Computers) {Write-Host “Restarting computer: $Computer”Restart-Computer -ComputerName $Computer -Force} In this script, you need to define an array of computer…
-
PowerShell Script to Create a New User
Here’s an example of a PowerShell script that can be used to install a new user: Define the user details (Parameters) $Username = “newuser”$Password = ConvertTo-SecureString “P@ssw0rd” -AsPlainText -Force$FullName = “New User”$Description = “This is a new user account.” Create a new user New-LocalUser -Name $Username -Password $Password -FullName $FullName -Description $Description -NoPasswordExpiration Add the…
-
Google Chrome History
This is a script I use to pull down browser history from accounts on PCs. I use this script to check on how user accounts are being used by students and staff to ensure devices are being used for work and not personal use. You need to change “USERNAME” to a user name found in:…
-
Remove Users from a PC using PowerShell
This document outlines how to remove users from a computer using PowerShell. Firstly, run PowerShell as an administrator and type the command: Get-WMIObject -class Win32_UserProfile | Where {(!$.Special) -and ($.ConvertToDateTime($_.LastUseTime) -lt (Get-Date).AddDays(-180))} | Remove-WmiObject This will remove the users that are over 180 days old. The parameter AddDays(-180) can be adjusted to any time length…
-
How to Remotely Deploy Installation Files and Install Software using PowerShell
Please note that this works well with scripts that are simple, using basic command prompt switches. I have tested this using more complex scripts that utilise Auto_It and Java scripts but for this document I will keep it simple. Please note that in this tutorial I refer to sessions using %destination and $deployment. This is…
-
Get Computer Information from Remote PC
Open PowerShell as an Administrator and type in this command: Invoke-Command -ComputerName ‘%PC_NAME%’ -ScriptBlock { Get-ComputerInfo } This will output all the information relating to target computer in PowerShell. This is a basic command but powerful when doing diagnostics or troubleshooting network issues. If you want to view the information of multiple computers just run…
-
Get a List of Installed Software Remotely
The method mentioned here can be used to check software installed on machines in the same network. You will need to run PowerShell as an administrator for this command to fully work. If you create a list of all the computer names in your network, you can use the method below within a Foreach loop…
-
Find Windows Updates History
To find the history of Windows Updates, open PowerShell as Administrator and type the command: get-hotfix get-wmiobject win32_quickfixengineering This command returns only the updates supplied by Component Based Servicing (CBS). These updates are not listed in the registry. Updates supplied by Microsoft Windows Installer (MSI) or the Windows update site (https://update.microsoft.com) are not returned by…
-
How to Restart a PC from PowerShell
Standalone Command Open PowerShell as an Administrator and type the command to restart a PC: Restart-Computer %PC Name% or Restart-Computer -ComputerName %PC Name% Note: A user cannot be logged in whilst running this command. The output shows an error. From a Text File Create a text file containing a group of PC names. Save it…
