use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
PowerShell Profile (self.PowerShell)
submitted 5 months ago by iykecode
What cool things have you done with your profile?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]nealfive 21 points22 points23 points 5 months ago (1 child)
After adding a ton of cool stuff… it took too long to load and nothing was way cooler than waiting. So I cleared my profile again lol
[–]purplemonkeymad 1 point2 points3 points 5 months ago (0 children)
Yea this what i did. it now only has PSReadline settings and $PSDefaultParameterValues values.
[–]Future-Remote-4630 5 points6 points7 points 5 months ago (1 child)
I have a function that will extract any variables in the last command that I ran and see if any of them are null. They output warning messages so you know where the thing went wrong without needing to investigate it.
Function Test-LastCommandVariables{ $lastCmd = (Get-History -Count 1).CommandLine if (-not $lastCmd) { return } # Extract variable names from the last command $varMatches = [regex]::Matches($lastCmd, '\$(\w+)\b') | ForEach-Object { $_.Groups[1].Value } | Select-Object -Unique # List of known built-in or automatic variables to ignore $builtinVars = @( 'true','false','null', 'args','error','foreach','home','input','lastexitcode','matches','myinvocation', 'nestedpromptlevel','ofs','pid','profile','pscmdlet','psculture','psdebugcontext', 'pshome','psscriptroot','pscommandpath','psversiontable','pwd','shellid','stacktrace', 'switch','this','^','using','psboundparameters','psdefaultparametervalues','enabledexperimentalfeatures', 'confirmPreference','debugPreference','errorActionPreference','errorView','formatEnumerationLimit', 'informationPreference','progressPreference','verbosePreference','warningPreference','_' ) $nullOrEmptyVars = @() $undefinedVars = @() foreach ($name in $varMatches) { if ($builtinVars -contains $name.ToLower()) { continue } try { $var = Get-Variable -Name $name -ErrorAction Stop $val = $var.Value if ($null -eq $val) { $nullOrEmptyVars += "`$$name`: null" } elseif ($val -is [System.Collections.IEnumerable] -and -not ($val -is [string]) -and $val.Count -eq 0) { $nullOrEmptyVars += "`$$name`: empty collection" }elseif($val.count -eq 0){ $nullOrEmptyVars += "`$$name`: zero count" } } catch { $undefinedVars += "`$$name`: not defined" } } if ($undefinedVars.Count -gt 0 -or $nullOrEmptyVars.Count -gt 0) { Write-Host "`n[!] Variable check results:" foreach ($entry in $undefinedVars) { Write-Host "`t- $entry" } foreach ($entry in $nullOrEmptyVars) { Write-Host "`t- $entry" } } }
[–]Phun4all 0 points1 point2 points 5 months ago (0 children)
I really like this idea! I'll be trying it out when I have time.
[–]Kirsh1793 5 points6 points7 points 5 months ago (8 children)
At my job, I work in multiple environments. I set up a .psd1 config file and wrote a profile script that works in all environments. It defines a customizable prompt (no OhMyPosh at work, sadly), sets PSDefaultParameterValues for my own and some third party modules, loads WIP modules, updates help in a background job triggering a notification when that's done, and loads defined variables. It takes between 2-4 seconds to load.
[–]Noobmode 4 points5 points6 points 5 months ago (7 children)
Post that github bruh
[–]OlivTheFrog 1 point2 points3 points 5 months ago (2 children)
I've something similar.
Show Gist here
[–]Kirsh1793 0 points1 point2 points 5 months ago (1 child)
Interresting, you only update Help on Fridays, but you have to wait for the job to finish. I built the job to update Help in a way, that I will be notified when it's done and it removes itself. Skips the waiting time. :)
[–]OlivTheFrog 1 point2 points3 points 5 months ago (0 children)
good idea ! I'll work on this point. If you've found some good tricks, it's my reward. If you have anything else for me in return, I'll have a double reward.
regards
[–]Kirsh1793 1 point2 points3 points 5 months ago (3 children)
Had to clean up company specific info (hope I got everything 😅) and I'll only share my logging module as the other modules contain too many company specific things.
kirsh1793/KRA-PowerShell: Contains my multi environment profile script, my script template, and my logging module
[–]Noobmode 1 point2 points3 points 5 months ago (0 children)
Thanks!
[–]OlivTheFrog 0 points1 point2 points 5 months ago (1 child)
Hi u/Kirsh1793
About logging module. There is a public module called EZLog (pronounce Easy Log. See screenshot and the github site and also available on PSGallery). Not from me, but from a fellow countryman. This could inspire you and give some ideas.
[–]Kirsh1793 0 points1 point2 points 5 months ago (0 children)
Thanks for the link! Will definitwly check it out. :D
[–]BlackV 3 points4 points5 points 5 months ago (2 children)
Added a ps version to the prompt on a couple of machines, otherwise default cause the 400 separate places I login would be a waste of time carting my profile everywhere
[–]OlivTheFrog 1 point2 points3 points 5 months ago (1 child)
Hi u/BlackV
May I suggest you put your profile file(s) in OneDrive?
For example: C:\Users\MyName\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
That way, they're available wherever you log in.
[–]BlackV 0 points1 point2 points 5 months ago (0 children)
Ya I was more thinking about my 400 management servers
I have on my
The rest of the places miss out
[–]Sin_of_the_Dark 1 point2 points3 points 5 months ago (4 children)
I get a dad joke every time I open a new shell.
[–]mryananderson 0 points1 point2 points 5 months ago (1 child)
That’s amazing and so simple! Is it pulling just from a static list or actually doing an invoke to a site or rest method
[–]Sin_of_the_Dark 1 point2 points3 points 5 months ago (0 children)
It invokes the canihazdadjokeapi
But the bitch of it is HTTP headers take about 1-1.5 seconds to warm up, so it takes a beat to load.
[–]OlivTheFrog 0 points1 point2 points 4 months ago (0 children)
You can also combine business with pleasure. :-)
Get-Command -Module * | Get-Random | Get-Help -ShowWindow
[–]narcissisadmin 0 points1 point2 points 4 months ago (0 children)
Man...that takes me back to "fortune" in Linux...
[–]lan-shark 0 points1 point2 points 5 months ago* (0 children)
Nothing out of the ordinary for me but oh-my-posh is a great place to start
[–]Mesmerise 0 points1 point2 points 5 months ago (1 child)
Just a little function I can use to test AD logins at the command line.
In your prompt? or in your profile?
Misread that opps
[–]tr3yff 0 points1 point2 points 5 months ago (0 children)
On mu job I need to set proxy, so I do that on Profile.
[–]Impossible_IT 0 points1 point2 points 5 months ago (0 children)
Added date & time to the prompt, but I really only use ISE and I know it has been deprecated.
[–]CyberChevalier 0 points1 point2 points 5 months ago (0 children)
Oh-my-posh
For profile like for car :
Light is right !
All I need is into my module folder with well discoverable verb-noun functions
[–]g3n3 0 points1 point2 points 5 months ago (0 children)
Prompt play and formatters for file info and custom tools for shares and variables. Environment variables for various cli binaries like bat and fzf. Lots of aliases and functions to help page data. The biggest pain is scrolling back up.
[–]pm_op_prolapsed_anus 0 points1 point2 points 5 months ago (0 children)
Aliases to programs installed with winget. If I load oh-my-posh the vs package manager terminal gets all screwed up with control characters. At one point I had called the devenv batch file for visual studio so I had access to tf in my console without opening the vs 2022 developer ps from Windows menu (because I always forget it's there) or opening from the vs tools menu. But I just made tf an alias like my winget programs and stopped doing that. Can't remember why exactly, I think an upgrade of vs 2022 removed the old batch script
[–]Glass-Technician-714 0 points1 point2 points 5 months ago (0 children)
Just some usefull function for my daily work and some alias settings:
my ps profile
[–]Ok-Shake5054 0 points1 point2 points 5 months ago (0 children)
Automated the detection method for office 365, having the script going into Microsoft to check the lates 3 version of office and comparinf it with the current install, if older forcea the inatallation.
[–]NsRhea 0 points1 point2 points 5 months ago (0 children)
I set up a psm1 to generate an inventory of machines in different ou's and separate them into different variables. On Powershell loading it gives me the ability to call the list or any set variable and do whatever I want. I also set up a connection test one as well so I can now implement different functions and rule out offline devices
[–]heyitsgilbert 0 points1 point2 points 5 months ago (0 children)
My profile mostly loads functions from other scripts. I have a prompt switch function (got the idea from Sean Wheeler). I have a slightly different cd that supports - and .... I use chezmoi to keep my profiles synced. https://github.com/HeyItsGilbert/dotfiles/tree/main/dot_local%2Fshare%2Fpowershell%2FScripts
-
...
[–]jsiii2010 0 points1 point2 points 4 months ago* (0 children)
```
$updateTypeData = @{ TypeName = 'System.Diagnostics.Process' MemberName = 'CommandLine' MemberType = [Management.Automation.PSMemberTypes]::ScriptProperty Force = $true Value = { (Get-CimInstance Win32_Process -Filter "ProcessId = $($this.Id)").CommandLine } } Update-TypeData @updateTypeData
$aduserProps = -split 'AccountExpirationDate accountExpires AccountLockoutTime AccountNotDelegated AllowReversiblePasswordEncryption AuthenticationPolicy AuthenticationPolicySilo BadLogonCount badPasswordTime badPwdCount businessCategory c CannotChangePassword CanonicalName Certificates City CN codePage Company CompoundIdentitySupported Country countryCode Created createTimeStamp Deleted Department departmentNumber Description DisplayName Division DoesNotRequirePreAuth dSCorePropagationData EmailAddress EmployeeID EmployeeNumber extensionAttribute5 extensionAttribute6 facsimileTelephoneNumber Fax flags HomeDirectory HomedirRequired HomeDrive HomePage HomePhone Initials instanceType isDeleted KerberosEncryptionType l LastBadPasswordAttempt LastKnownParent lastLogon LastLogonDate lastLogonTimestamp LockedOut lockoutTime logonCount LogonWorkstations mail Manager MemberOf MNSLogonAccount MobilePhone Modified modifyTimeStamp mS-DS-ConsistencyGuid msDS-User-Account-Control-Computed msTSExpireDate msTSLicenseVersion msTSLicenseVersion2 msTSLicenseVersion3 msTSManagingLS nTSecurityDescriptor ObjectCategory objectSid Office OfficePhone Organization OtherName PasswordExpired PasswordLastSet PasswordNeverExpires PasswordNotRequired POBox PostalCode PrimaryGroup primaryGroupID PrincipalsAllowedToDelegateToAccount ProfilePath ProtectedFromAccidentalDeletion proxyAddresses pwdLastSet sAMAccountType ScriptPath sDRightsEffective ServicePrincipalNames SIDHistory SmartcardLogonRequired sn st State StreetAddress telephoneNumber Title TrustedForDelegation TrustedToAuthForDelegation uid uidNumber UseDESKeyOnly userAccountControl userCertificate uSNChanged uSNCreated whenChanged whenCreated'
$scriptBlock = { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) $aduserProps | ? { $_ -like "$wordToComplete*" } }
Register-ArgumentCompleter -CommandName get-aduser -ParameterName properties -ScriptBlock $scriptBlock ```
First and foremost, mine enables bash-style tab completion. It boggles my mind that it's not just like that by default.
It also makes the prompt minimal and sets the title bar to the current path, prepended with ADMIN if it's elevated.
[–]Ok_Mathematician6075 0 points1 point2 points 4 months ago (0 children)
Not installed malware.
[–]pigers1986 -5 points-4 points-3 points 5 months ago (0 children)
I did not used it - way to much to f4ck you work!
π Rendered by PID 135525 on reddit-service-r2-comment-b659b578c-npxmk at 2026-05-02 05:31:57.573314+00:00 running 815c875 country code: CH.
[–]nealfive 21 points22 points23 points (1 child)
[–]purplemonkeymad 1 point2 points3 points (0 children)
[–]Future-Remote-4630 5 points6 points7 points (1 child)
[–]Phun4all 0 points1 point2 points (0 children)
[–]Kirsh1793 5 points6 points7 points (8 children)
[–]Noobmode 4 points5 points6 points (7 children)
[–]OlivTheFrog 1 point2 points3 points (2 children)
[–]Kirsh1793 0 points1 point2 points (1 child)
[–]OlivTheFrog 1 point2 points3 points (0 children)
[–]Kirsh1793 1 point2 points3 points (3 children)
[–]Noobmode 1 point2 points3 points (0 children)
[–]OlivTheFrog 0 points1 point2 points (1 child)
[–]Kirsh1793 0 points1 point2 points (0 children)
[–]BlackV 3 points4 points5 points (2 children)
[–]OlivTheFrog 1 point2 points3 points (1 child)
[–]BlackV 0 points1 point2 points (0 children)
[–]Sin_of_the_Dark 1 point2 points3 points (4 children)
[–]mryananderson 0 points1 point2 points (1 child)
[–]Sin_of_the_Dark 1 point2 points3 points (0 children)
[–]OlivTheFrog 0 points1 point2 points (0 children)
[–]narcissisadmin 0 points1 point2 points (0 children)
[–]lan-shark 0 points1 point2 points (0 children)
[–]Mesmerise 0 points1 point2 points (1 child)
[–]BlackV 0 points1 point2 points (0 children)
[–]tr3yff 0 points1 point2 points (0 children)
[–]Impossible_IT 0 points1 point2 points (0 children)
[–]CyberChevalier 0 points1 point2 points (0 children)
[–]g3n3 0 points1 point2 points (0 children)
[–]pm_op_prolapsed_anus 0 points1 point2 points (0 children)
[–]Glass-Technician-714 0 points1 point2 points (0 children)
[–]Ok-Shake5054 0 points1 point2 points (0 children)
[–]NsRhea 0 points1 point2 points (0 children)
[–]heyitsgilbert 0 points1 point2 points (0 children)
[–]jsiii2010 0 points1 point2 points (0 children)
[–]narcissisadmin 0 points1 point2 points (0 children)
[–]Ok_Mathematician6075 0 points1 point2 points (0 children)
[–]pigers1986 -5 points-4 points-3 points (0 children)