Pretty simple script, this just remove files from your downloads folder that are older than x amount of days (by default its set to 60).
$Paths = @(
"%userprofile%\Downloads\"
)
$Days = 60
$limit = (Get-Date).AddDays(-$Days)
foreach ($Path in $Paths)
{
# Delete files older than the...
After writing about prompt customizations, I realized that I likely need to address a common issue that pops up when users are first configuring their PowerShell (PS) environment. If you have not read that post yet, I would start there before continuing with this one. As we discussed in that...
I have a thing about command line prompts. I like tweaking and customizing. The prompt is such a simple thing, but impacts experience dramatically. Once I learned about prompt customization, I found a general format that works for me and can be replicated across multiple environments and...
Just a quick script on creating URL Shortcuts, defaults to the Public user desktop and has support for custom icons.
param (
[string]$Path,
[Parameter(Mandatory=$true)]
[string]$Name,
[Parameter(Mandatory=$true)]
[string]$URL,
[string]$IconUrl,
[string]$IconPath =...
This was quick and dirty / probably needs some more work I'll add it to GitHub later.
Import-Module ActiveDirectory
if ((Get-ADOptionalFeature -Identity 'Recycle Bin Feature').EnabledScopes)
{
Write-Host "AD Recycle Bin Enabled"
}
else
{
try
{
$domain = Get-WmiObject...
Just a way to clear print jobs that may be stuck "printing" or if they are in error status.
$PrintJobs = get-wmiobject -class "Win32_PrintJob" -namespace "root\CIMV2" -computername "."
foreach ($job in $PrintJobs) {
$pos = ($job.Name).IndexOf(",")
$printerName =...
The process of hard linking AD objects to AAD objects for when you get errors during an AD Sync.
On the domain controller run:
Get-ADUser username | Select-Object UserPrincipalName, objectGUID, @{Name = 'ImmutableID'; Expression = {...
Pretty simple script that will answer to what process is using a port.
param(
[Parameter(Mandatory=$true)]
[string]$port #e.g. 443
)
# Pull PID from TCP Connections and then outputs process name(s)
$pids = (Get-NetTCPConnection | Where-Object { $_.LocalPort -eq $port }) |...
This is a pretty simple one, but it gives you a list of users where litigation hold is not enbaled.
Connect-ExchangeOnline -UserPrincipalName <global-admin-account>
Get-Mailbox | Where-Object { $_.LitigationHoldEnabled -eq $false }
Simple way to get the version of an application via PowerShell.
Param(
[Parameter(Mandatory=$true)]
$ApplicationName
)
$InstalledSoftware = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
if($ApplicationName -ne $null) {
foreach($obj in...
Have you ever wanted to run a script that would just clear the user's errored print queue? With this you can put it in your RMM and have it run against a users machine and the print server (so it clears out anything that is errored).
$PrintJobs = get-wmiobject -class "Win32_PrintJob" -namespace...
Battery Status
This will return an error if something is wrong otherwise it will return "Healthy."
param(
[string]$StorCLILocation = 'C:\Program Files (x86)\MegaRAID Storage Manager\StorCLI.exe', # Path to StorCLI
[string]$StorCliCommand = "/c0 /bbu show status j"
)
try {...
The base for each of these snippets were written over at CyberDrain and I've modified them for running other commands / providing the output that we need.
Battery Status
This will return an error if something is wrong otherwise it will return "Healthy."
$cmd = (&"C:\Program...
So there are times that you may need to run an exe across many devices, and maybe those devices are across several organizations or not on a Windows Domain. With this script you can upload the file to a central web server and the script will download the file and run it on devices.
Note: This...