Guy Leech
Blogs, Articles, and Posts
Find cmdlets with -ComputerName parameter
(twitter.com)
Today my granddaughter asked me what PowerShell cmdlets take a -ComputerName parameter so can be
By: Guy Leech submitted:Jun 16 2022
Today my granddaughter asked me what PowerShell cmdlets take a -ComputerName parameter so can be
self-remoted so I gave her this:
By: Guy Leech submitted:Jun 16 2022
For those that were asking about splatting in PowerShell
(twitter.com)
recently (where you pass a hashtable containing the parameters rather than passing named parameters
By: Guy Leech submitted:Jun 16 2022
recently (where you pass a hashtable containing the parameters rather than passing named parameters
(never use positional parameters!)), you can multi-splat if you need to as I do here
By: Guy Leech submitted:Jun 16 2022
FYI you can use square brackets with wildcards in PowerShell Select-Object (alias select)
(twitter.com)
to restrict the wildcard eg here I only want name properties beginning with C or D so I use
By: Guy Leech submitted:Aug 5 2022
to restrict the wildcard eg here I only want name properties beginning with C or D so I use
[CD]*name where square brackets is same as in regex & means 1 of. Use ? to match single character
By: Guy Leech submitted:Aug 5 2022
I’m too lazy to put text I want to search for into the clipboard from a PowerShell window
(twitter.com)
get a new browser tab & paste it in to get search results so I added $google variable to my $profile
By: Guy Leech submitted:Jun 16 2022
get a new browser tab & paste it in to get search results so I added $google variable to my $profile
so I can search thus
By: Guy Leech submitted:Jun 16 2022
If you want to see all scheduled tasks in a single pane
(twitter.com)
Another great sweet and slick tip from Guy.
By: Guy Leech submitted:Jun 15 2022
Another great sweet and slick tip from Guy.
By: Guy Leech submitted:Jun 15 2022
Just been asked to try to speed up a PowerShell loop
(twitter.com)
notice how much slower Get-Date is than using -as or a cast. Using -as also has the advantage that
By: Guy Leech submitted:Jun 16 2022
notice how much slower Get-Date is than using -as or a cast. Using -as also has the advantage that
it doesn't error with bad date format it just returns $null which you can check for. Use TryParseExact for non-standard ones
By: Guy Leech submitted:Jun 16 2022
Lest you were wondering which the fastest algorithms were to use in PowerShell Get-FileHash
(mobile.twitter.com)
(available in v4+), I've knocked up a quick script. All are equally CPU intensive.
By: Guy Leech submitted:Jun 16 2022
(available in v4+), I've knocked up a quick script. All are equally CPU intensive.
By: Guy Leech submitted:Jun 16 2022
Need to remove formatting, etc from clipboard contents to paste into something that doesn’t have a text only paste?
(twitter.com)
Create a desktop shortcut thus, problem solved
By: Guy Leech submitted:Jun 16 2022
Create a desktop shortcut thus, problem solved
By: Guy Leech submitted:Jun 16 2022
PowerShell 1 liner
(twitter.com)
to run on domain controllers to show AD account lock out events & the device they occurred on
By: Guy Leech submitted:Jun 16 2022
to run on domain controllers to show AD account lock out events & the device they occurred on
By: Guy Leech submitted:Jun 16 2022
PowerShell Remoting for Troubleshooting Purposes | ScriptRunner
(scriptrunner.com)
I'm going to show you ways to perform troubleshooting, remotely, for instance when the problem is
By: Guy Leech submitted:Jun 16 2022
I'm going to show you ways to perform troubleshooting, remotely, for instance when the problem is
that a GUI based logon such as through mstsc or the physical or virtual console hangs/goes slowly.
By: Guy Leech submitted:Jun 16 2022
Process CPU Usage Limit
(controlup.com)
Finds threads over consuming CPU in the selected process and reduces their average CPU consumption
By: Guy Leech submitted:Jun 15 2022
Finds threads over consuming CPU in the selected process and reduces their average CPU consumption
based on the agressiveness argument. The higher the agressiveness, the more CPU throttling is performed. The number can be between 1 and 10 including decimal places. A duration can be set, in minutes or parts there of, for how long the selected process will be monitored/adjusted but if set to 0 then the process will be monitored/adjusted until it exits. WARNING: This may make interactive applications become sluggish for users if they are targeted.
By: Guy Leech submitted:Jun 15 2022
Since mmc won’t do it here’s PowerShell to clone a scheduled task running under an arbitrary account
(twitter.com)
Another slick solution from Guy Leech
By: Guy Leech submitted:Jun 16 2022
Another slick solution from Guy Leech
By: Guy Leech submitted:Jun 16 2022
TIL (accidentally) that PowerShell Copy-Item has -ToSession
(twitter.com)
(and -FromSession) parameters so you can copy files/folders to/from remote machines without needing
By: Guy Leech submitted:Aug 12 2022
(and -FromSession) parameters so you can copy files/folders to/from remote machines without needing
$ shares. Best to set $ProgressPreference to SilentlyContinue unless you want it slowed by progress messages
By: Guy Leech submitted:Aug 12 2022
Want a quick way to see what drivers you have and search/filter/sort?
(twitter.com)
Run this PowerShell (uses aliases, see screenshot for full cmdlet & parameter names which is what
By: Guy Leech submitted:Jun 16 2022
Run this PowerShell (uses aliases, see screenshot for full cmdlet & parameter names which is what
should be used in scripts)
By: Guy Leech submitted:Jun 16 2022
Want to “tail” a text file in real-time?
(twitter.com)
Get-Content (alias gc) will do it
By: Guy Leech submitted:Jun 16 2022
Get-Content (alias gc) will do it
By: Guy Leech submitted:Jun 16 2022
Where did that download come from?
(guyrleech.wordpress.com)
I was investigating something completely unrelated recently when I came across the fact that the
By: Guy Leech submitted:Jun 15 2022
I was investigating something completely unrelated recently when I came across the fact that the
Zone.Identifier information for downloaded files, on Windows 10, which is stored in NTFS Alternate Data Streams (ADS) on each downloaded file, contains the URL from which the file came. Yes, the whole URL so could potentially be very useful and/or very embarrassing. It's this Zone.Identifier file that Windows Explorer checks when it puts restrictions on files that it deems could be unsafe because they have come from the internet zone.
By: Guy Leech submitted:Jun 15 2022
Projects, Scripts, and Modules
Create log file with date elements in path
(pastebin.com)
$logFile passed as a parameter such as
By: Guy Leech submitted:Jun 16 2022
$logFile passed as a parameter such as
"%systemdrive%%year%%monthname%blah-%hour%.%minute%-y%.%month%.%year%.log"
By: Guy Leech submitted:Jun 16 2022
Export all GPOs to a folder
(pastebin.com)
Quick script to export all GPOs
By: Guy Leech submitted:Jun 16 2022
Quick script to export all GPOs
By: Guy Leech submitted:Jun 16 2022
Get Scheduled Task completion statuses
(pastebin.com)
PowerShell 1 liner to get the history of scheduled task completion statuses - export to csv or
By: Guy Leech submitted:Jun 16 2022
PowerShell 1 liner to get the history of scheduled task completion statuses - export to csv or
display in grid view to filter on a specific task and see when/if it returned a fail
By: Guy Leech submitted:Jun 16 2022
Regrecent.ps1
(github.com)
Here's a PowerShell script, based on C++ code I wrote 20+ years ago, that allows you to search the
By: Guy Leech submitted:Jun 16 2022
Here's a PowerShell script, based on C++ code I wrote 20+ years ago, that allows you to search the
registry based on key timestamps (note that values do not have timestamps).
By: Guy Leech submitted:Jun 16 2022
Send to Viewer.ps1
(github.com)
Simple text viewer so won't add history anywhere. Takes multiple files, from explorer send to, or if
By: Guy Leech submitted:Jun 16 2022
Simple text viewer so won't add history anywhere. Takes multiple files, from explorer send to, or if
no files, uses clipboard
By: Guy Leech submitted:Jun 16 2022
Show file download time & rate
(pastebin.com)
How long did it take (roughly) to download that file and what was the average download speed?
By: Guy Leech submitted:Jun 16 2022
How long did it take (roughly) to download that file and what was the average download speed?
Assuming file not modified since download, here's PowerShell to do it
By: Guy Leech submitted:Jun 16 2022
VMware/Run script in VM
(github.com)
Copy a script to a remote machine via Invoke-VMScript, as doesn't require explicitly specified
By: Guy Leech submitted:Jun 16 2022
Copy a script to a remote machine via Invoke-VMScript, as doesn't require explicitly specified
credentials, and run it. Works around an issue that limits PowerShell script length to 8K because VMware run powershell.exe via cmd.exe.
By: Guy Leech submitted:Jun 16 2022
Books, Media, and Learning Resources
Driving the Citrix Cloud REST API with PowerShell – UK CUGC Dec 2021 – YouTube
(youtube.com)
In this session, CTP Guy Leech walks through how to authenticate to Citrix Cloud via OAuth, and how
By: Guy Leech submitted:Jun 16 2022
In this session, CTP Guy Leech walks through how to authenticate to Citrix Cloud via OAuth, and how
to query and update CVAD configuration via the Citrix Cloud REST APIs using PowerShell, without the need for any Citrix PowerShell modules
By: Guy Leech submitted:Jun 16 2022
Fun
Have they never heard of PowerShell?
(twitter.com)
No love, I tell ya
By: Guy Leech submitted:Jun 16 2022
No love, I tell ya
By: Guy Leech submitted:Jun 16 2022