After much searching online I couldn't find a way to do this without WMI and a bunch of extra work... So I figured this out. Tested and working in Windows 10 at least.
$user = "$env:USERDOMAIN\$env:USERNAME"
$proc = Get-Process -Name notepad -IncludeUserName | where {$_.UserName -eq $user}
Wait-Process -InputObject $proc
That will look for all instances of notepad running under the current user, and wait for all of them to terminate before continuing.
Super useful when waiting for something like msiexec
Showing posts with label powershell. Show all posts
Showing posts with label powershell. Show all posts
Monday, 4 December 2017
Wednesday, 17 May 2017
Windows Updates via Powershell
This requires Powershell V5. The powershell script to install the module is:
$psversion = $PSVersionTable.PSVersion.Major
if ($psversion -ge 5){
Install-PackageProvider -Name NuGet -Force
Install-Module -Name PSWindowsUpdate -Force -Scope AllUsers
Get-WUServiceManager
}else{
echo "Error, PS is out of date"
}
Then, to run it simple use:
"Get-WuInstall -AcceptAll -IgnoreUserInput -AutoReboot -Confirm:$false -nottitle 'preview' -updatecount 30"
(Update count just limits the amount it does at once, so if there is an error with one it doesn't undo them all. Good for computers very out of date.)
The github for this module is located at:
https://github.com/joeypiccola/PSWindowsUpdate
$psversion = $PSVersionTable.PSVersion.Major
if ($psversion -ge 5){
Install-PackageProvider -Name NuGet -Force
Install-Module -Name PSWindowsUpdate -Force -Scope AllUsers
Get-WUServiceManager
}else{
echo "Error, PS is out of date"
}
Then, to run it simple use:
"Get-WuInstall -AcceptAll -IgnoreUserInput -AutoReboot -Confirm:$false -nottitle 'preview' -updatecount 30"
(Update count just limits the amount it does at once, so if there is an error with one it doesn't undo them all. Good for computers very out of date.)
The github for this module is located at:
https://github.com/joeypiccola/PSWindowsUpdate
Wednesday, 30 April 2014
Apt-get upgrade in Powershell V5 oneget
After much playing around, the closest I could get to apt-get upgrade in the preview of Powershell V5 using OneGet is the following:
Get-Package | Select-Object -ExpandProperty name | Find-Package | Install-Package -Force
Get-Package | Select-Object -ExpandProperty name | Find-Package | Install-Package -Force
Subscribe to:
Posts (Atom)
Proxmox Backup Server - Recover a ZFS Datastore that is 100% full
This has happened to me a couple times now where my ZFS pool has filled to 100% causing not only backups to fail, but also the ability to ru...
-
If you are recieving the following error: The session setup from the computer COMPUTERNAME failed to authenticate. The name(s) of the acco...
-
Relevant Errors: Failed to prepare guest for hot backup. Error: VSSControl: -2147212529 Backup job failed. Discovery phase failed. Can...
-
Below is the Docker Compose script to setup Graylog. Copy and paste this then make a new Project with this script. The default password I us...