Tips and tricks for when we don't have local admin rights
First presented at PowerShell Conference Europe 2022
When we are on Windows we don't need to install anything to get it started.
Just search for ISE in the Start menu to show find Windows PowerShell ISE
.
ISE stands for Integrated Scripting Environment
ISE is perfectly enough!
The $profile
file will get executed every time when we start PowerShell, so this is where we can constomize our experience. (But it does not exists by default)
Write-Host $profile
Test-Path $profile
New-Item $profile -ItemType File
New-Item $profile -ItemType File -Force
Let's try it!
Execution policy in PowerShell is like something eveyone runs into and turns off...
Get-ExecutionPolicy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
# Try scoping it to us
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# if RemoteSigned does not work, just use Bypass
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser
As others have already said it, color red is bad, so let's use something nicer
$host.PrivateData.ErrorForegroundColor = 'Green'
# and try it
1/0
Also, save this into our profile, because this is not a persistent setting.
The PowerShell Gallery is from where we can get the goodies, like QR code generator
Find-Module QRCodeGenerator
Find-Module QR*
Install-Module QRCodeGenerator
Install-Module QRCodeGenerator -Scope CurrentUser
PowerShell has the most awesome extensible help system
Get-Help
But sadly by default it comes empty, and we need to download the help with admin rights so here we need to ask help from our - hopefully - friendly neighbourhood IT admin, or help desk person to run this command as a local admin on our machine
Update-Help -Force -ErrorAction SilentlyContinue
So we can use Get-Help
without any errors.
Get-Help
Get-Member
Get-Command
Get-Command Get-*
Get-Command Set-*
Get-Command *-Computer
$ProgressPreference = 'SilentlyContinue'
$PSDefaultParameterValues["Install-Module:Scope"] = "CurrentUser"
Influenced by Mike F Robbins
PowerShell 101: The No-Nonsense Beginner’s Guide to PowerShell
And also by Chrissy LeMaire's Tweet