r/PowerShell • • May 14 '19

PowerShell commands you can't live without.

125 Upvotes

Hello everyone, I'm traversing into the PowerShell realm after using Linux and want a little jumpstart. So I ask what commands can't you live without or wished you learned earlier to make your life easier? Thanks all for your help!


r/PowerShell • • May 02 '18

2018 PowerShell Summit Videos

Thumbnail
m.youtube.com
125 Upvotes

r/PowerShell • • Aug 30 '17

[TIL] You can change the tab complete behaviour in newer versions of PowerShell

125 Upvotes

One of my biggest gripes with PowerShell's tab complete has always been that I type Get-AD<tab> looking for Get-ADUser but get Get-ADAccountAuthorizationGroup instead and have to backspace all those characters or hit tab 50 times to get to ADUser.

I much prefer how bash works and today it was pointed out to me that you can come close in PowerShell:

Set-PSReadlineKeyHandler -Key Tab -Function Complete

Which is bash like or another option:

Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

Which gives you an arrow navigable list of possible completion choices and is also kind of bash like.

You can set it on demand or add it to your $Profile. There's a bunch of other cool stuff in PSReadLine https://docs.microsoft.com/en-us/powershell/module/psreadline/?view=powershell-5.1 but I think tab completion control takes the cake for me. It's not perfect but it's better than the default. (Ctrl+Space is 'MenuComplete' by default if you do not want to change tab itself. Get-PSReadlineKeyHandler)


r/PowerShell • • May 26 '26

Script Sharing Mastering Markdown with PowerShell

124 Upvotes

I've loved Markdown since the day it was a Daring Fireball post.

It's a simple rich text format that gets the job done, and it's used everywhere.

Markdown in PowerShell

Markdown is supported out of the box on PowerShell 6+, using the ConvertFrom-Markdown command.

Here's it in action:

"# Hello World" |
    ConvertFrom-Markdown |
    Select -Expand HTML

Like any other page in a static site, Markdown is just text.

And PowerShell is Pretty Good at manipulating text.

To make PowerShell that outputs markdown, just make simple scripts that spit out text.

Markdown Static Sites

One very simple use of this technique is making static sites with Markdown.

If we don't want to worry about look and feel too much, we can do this with the following pipeline:

"# Markdown" | 
    ConvertFrom-Markdown | 
        Select-Object -ExpandProperty Html >
            ./markdown.html

If we wanted to make a page for every file in the directory, we could:

foreach ($file in Get-ChildItem *.md -File) {
    ConvertFrom-Markdown -LiteralPath $file.Fullname |
        Select-Object -ExpandProperty Html > (
            $file.Fullname -replace '\.md$', '.html'
        )
}

That's a static site generator in six lines of PowerShell!

Here's an even shorter version:

foreach ($file in Get-ChildItem *.md -File) {        
    $html = (ConvertFrom-Markdown -Path $file.Fullname).html
    $html > ($file.Fullname -replace '\.md$', '.html') 
}

Now we've got a static site generator in four lines!

Static Sites are Simple (with PowerShell).

To make websites in PowerShell, all we need to do is loop over markdown and optionally add some layout.

Making Markdown

We can make markdown in PowerShell by just outputting text.

@(
    "# Hello World"
    "## How Are You?"
    "Today is $([DateTime]::Now.ToShortDateString())"
) > ./example.md

Each line of output will become a line in the markdown file.

We can use conditionals if we want to. Let's switch it up by including the day of week.

@(
    "# Hello World"
    switch ([DateTime]::Now.DayOfWeek) {
        Monday { "Just Another Manic Monday "}
        Tuesday { "Taco Tuesday" }
        Wednesday { "Halfway thru the week! "}
        Thursday { "Almost Friday" }
        Friday { "Happy Friday! "}
        Saturday { "It's the weekend!"}
        default { "It is $([DateTime]::Now.DayOfWeek)" }
    }
) > ./example.md

Making Markdown with Functions

We can make functions that output markdown.

Here's a simple one that outputs headings

function markdown.heading {
    param(
        [string]$Message = 'Hello World',
        [ValidateRange(1,6)]$Level = 1
    )
    # Multiply our heading character by our level
    # and put a space in between the heading and message
    ('#' * $level), $Message -join ' ''
}

markdown.heading "Markdown Functions" 
markdown.heading "Are just functions" -Level 2
markdown.heading "That output markdown" -Level 3

Since markdown functions are just PowerShell functions, we can put whatever we want in there.

function markdown.get.process {
    # Markdown tables have a header row
    "|Name|Id|"
    # Followed by a row that aligns text
    "|:-|-:|"
    # Followed by any number of rows of data
    foreach ($process in Get-Process) {
        '|' + (
            $process.Name, $process.Id -join '|'
        ) + '|'
    }
}

markdown.get.process > ./process.md

Now we hopefully see how easy it is to make markdown in PowerShell.

Just spit out strings.

This is already probably cool enough, but why not make markdown into something we can query?

Making Markdown into XML

ConvertFrom-Markdown converts Markdown into HTML.

It's just a hop, skip, and a jump to make this markdown into XML.

Because all of our tags are perfectly balanced, we can make markdown in XML by just putting it into another element.

Cannonically, I prefer putting markdown into an <article> element

@(
    "<article>"
    ("# Hello World" | ConvertFrom-Markdown).html
    "</article>"
) -join '' -as [xml]

That's it! We've turned a easy old markdown into hard-to-write XML.

Why is this useful?

Because now we can query markdown.

Markdown, XML, and XPath

To show this in action, let's start really simple:

Let's just get all of the nodes in some markdown

@(
    "# Hello World"
    "## Don't mind me"
    "### Just about to turn markdown into XML"
    "> This is pretty cool, right?"
) -join [Environment]::Newline |
    ConvertFrom-Markdown |
    Foreach-Object {
        "<article>$($_.Html)</article>" -as [xml]
    } |
    Select-Xml //*        

Let's get all link hrefs in some markdown:

# Make some markdown
@(
    "# Some Links"
    "* [StartAutomating on GitHub](https://github.com/StartAutomating/)"
    "* [PoshWeb on GitHub](https://github.com/PoshWeb/)"
    "* [MarkX](https://github.com/PoshWeb/MarkX)"
) -join [Environment]::Newline | 
    # convert it from markdown
    ConvertFrom-Markdown |
    # turn it into xml
    Foreach-Object {
        "<article>$($_.Html)</article>" -as [xml]
    } |
    # pipe it to Select-Xml, picking out any `<a>` elements
    Select-Xml //a |
    Foreach-Object { 
        $_.Node.Href
    }

This is still the tip of the iceberg.

Turning Markdown into XML lets us query and manipulate Markdown in all sorts of interesting ways.

What can you do with Markdown and PowerShell? Almost anything.

Mark My Words

  • Markdown is a simple rich text format.

  • PowerShell is pretty perfect for making Markdown.

  • XPath is excellent at extracting information from Markdown.

You can do a lot of cool things when you mix Markdown with PowerShell.

What do you want to try?


r/PowerShell • • Oct 24 '25

Question When are you actually going to FINISH GraphAPI? Like seriously? When?

124 Upvotes

That's it. When? Or in GraphAPI speak:

Microsoft-QueryMicrosoft -query "When will you finish the GraphAPI'?" -user "Everyone" -scope "TheWorld" -credential "[email protected]" -AskMicrosoftDevOps "yes" -WaitResponse "no" -FindAlternativeAPI "no" -ConsiderNeverAnAnswer "no" -AskWhyTheyThrottleSoHeavily "yes" -AskIfTheyCanUseThoseAbsurdProfitsToFinishTheJob "yes" -RequestReasonSwitchesRequireSoManyWordsToFunction "yes"


r/PowerShell • • Mar 06 '23

Script Sharing I Recreated "Edgar the Virus Hunter" from SBEmail 118 Where Strongbad's Compy 386 Gets a Virus. Complete with ASCII Graphics and Sound!

124 Upvotes

I recreated the entire program in Powershell, complete with ASCII graphics, and accurate sound-effects. I listened to the original, figured out what notes made up the sound effects, then used this table to convert those tones to their corresponding frequencies. https://pages.mtu.edu/~suits/notefreqs.html Give it a try and let me know what you think!

##################################################
#Edgar the Virus Hunter - Powershell Edition v1.0#
#Author: u/MessAdmin                             #
##################################################


#Scan state array
$scanarray = @(
'[)...................]'
'[))..................]'
'[))).................]'
'[))))................]'
'[)))))...............]'
'[))))))..............]'
'[))))))).............]'
'[))))))))............]'
'[)))))))))...........]'
'[))))))))))..........]'
'[))))))))))).........]'
'[))))))))))))........]'
'[))))))))))))).......]'
'[))))))))))))))......]'
'[))))))))))))))).....]'
'[))))))))))))))))....]'
'[)))))))))))))))))...]'
'[))))))))))))))))))..]'
'[))))))))))))))))))).]'
'[))))))))))))))))))))]'
)

#Splash Screen
cls

'    XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
'  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
' XXXXXXXXXXXXXXXXXX         XXXXXXXX'
'XXXXXXXXXXXXXXXX              XXXXXXX'
'XXXXXXXXXXXXX                   XXXXX'
' XXX     _________ _________     XXX      '
'  XX    I  _xxxxx I xxxxx_  I    XX        '
' ( X----I         I         I----X )        '   
'( +I    I      00 I 00      I    I+ )'
' ( I    I    __0  I  0__    I    I )'
'  (I    I______ /   _______I    I)'
'   I           ( ___ )           I'
'   I    _  :::::::::::::::  _    i'
'    \    ___ ::::::::: ___/    /'
'     _      _________/      _/'
'       \        ___,        /'
'         \                 /'
'          |\             /|'
'          |  _________/  |'
'       ======================'
'       |---Edgar the Virus---'
'       |-------Hunter-------|'
'       |Programmed entirely-|'
"       |in mom's basement---|"
'       |by Edgar------(C)1982'
'       ======================'

#Splash SFX
[Console]::Beep(1567.98,90)
[Console]::Beep(1567.98,90)
[Console]::Beep(1760,90)
[Console]::Beep(1567.98,90)
[Console]::Beep(1760,90)
[Console]::Beep(1975.53,90)

Read-Host 'Press ENTER to continue.'
cls

#Scanning...

Foreach($state in $scanarray){
cls
'=========================='
'|---Virus Protection-----|'
'|-----version .0001------|'
'|------------------------|'
'|Last scan was NEVER ago.|'
'|------------------------|'
'|-------scanning...------|'
"|--$state|"
'=========================='
Start-Sleep -Milliseconds 500
}
cls

#Scan Complete

##GFX
'================'
'|Scan Complete!|'
'|--------------|'
'|---423,827----|'
'|Viruses Found-|'
'|--------------|'
'|A New Record!!|'
'================'

##SFX
[Console]::Beep(783.99,700)

Start-Sleep -Seconds 8
cls

#Flagrant System Error

##SFX
[Console]::Beep(329.628,150)
[Console]::Beep(415.30,50)
[Console]::Beep(445,700)

##GFX
While($true){
cls
'          FLAGRANT SYSTEM ERROR          '
''
'             Computer over.              '
'            Virus = Very Yes.            '
Start-Sleep -Seconds 10
}

r/PowerShell • • Feb 16 '23

Found these tools on Microsoft Learn seem to be based on mostly sysinternals and other known tools ?

124 Upvotes

Introduction to TroubleShootingScript toolset (TSSv2) - Windows Client | Microsoft Learn zip file linked here , seem pretty useful things like poolmon and WPR and many many more scripts all official and too be fair pretty advanced too, i did a search and it's not been posted here before which is insane to think really!!


r/PowerShell • • Aug 26 '21

Information Calling REST from PowerShell including authorization and body constructs

Thumbnail
youtu.be
124 Upvotes

r/PowerShell • • Aug 17 '20

Module Monday: PSKoans

Thumbnail
youtu.be
124 Upvotes

r/PowerShell • • Jul 21 '20

Fun With Powershell - Mario Themes (not OC)

124 Upvotes

Reminder: always check PS code from 3rd parties.

Edit: Shout out to /u/geostude for creating this fun code!

[Console]::Beep(130, 100)
[Console]::Beep(262, 100)
[Console]::Beep(330, 100)
[Console]::Beep(392, 100)
[Console]::Beep(523, 100)
[Console]::Beep(660, 100)
[Console]::Beep(784, 300)
[Console]::Beep(660, 300)
[Console]::Beep(146, 100)
[Console]::Beep(262, 100)
[Console]::Beep(311, 100)
[Console]::Beep(415, 100)
[Console]::Beep(523, 100)
[Console]::Beep(622, 100)
[Console]::Beep(831, 300)
[Console]::Beep(622, 300)
[Console]::Beep(155, 100)
[Console]::Beep(294, 100)
[Console]::Beep(349, 100)  
[Console]::Beep(466, 100)
[Console]::Beep(588, 100)
[Console]::Beep(699, 100)
[Console]::Beep(933, 300)
[Console]::Beep(933, 100)
[Console]::Beep(933, 100)
[Console]::Beep(933, 100)
[Console]::Beep(1047, 400)   

and

function b($a,$b){
    [console]::beep($a,$b)
}
function s($a){
    sleep -m $a
}
write-host "Super Mario!"
b 660 100;
s 150;
b 660 100;
s 300;
b 660 100;
s 300;
b 510 100;
s 100;
b 660 100;
s 300;
b 770 100;
s 550;
b 380 100;
s 575;

b 510 100;
s 450;
b 380 100;
s 400;
b 320 100;
s 500;
b 440 100;
s 300;
b 480 80;
s 330;
b 450 100;
s 150;
b 430 100;
s 300;
b 380 100;
s 200;
b 660 80;
s 200;
b 760 50;
s 150;
b 860 100;
s 300;
b 700 80;
s 150;
b 760 50;
s 350;
b 660 80;
s 300;
b 520 80;
s 150;
b 580 80;
s 150;
b 480 80;
s 500;

b 510 100;
s 450;
b 380 100;
s 400;
b 320 100;
s 500;
b 440 100;
s 300;
b 480 80;
s 330;
b 450 100;
s 150;
b 430 100;
s 300;
b 380 100;
s 200;
b 660 80;
s 200;
b 760 50;
s 150;
b 860 100;
s 300;
b 700 80;
s 150;
b 760 50;
s 350;
b 660 80;
s 300;
b 520 80;
s 150;
b 580 80;
s 150;
b 480 80;
s 500;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 220;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 200;
s 300;

b 1020 80;
s 300;
b 1020 80;
s 150;
b 1020 80;
s 300;

b 380 100;
s 300;
b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 420;

b 585 100;
s 450;

b 550 100;
s 420;

b 500 100;
s 360;

b 380 100;
s 300;
b 500 100;
s 300;
b 500 100;
s 150;
b 500 100;
s 300;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 220;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 200;
s 300;

b 1020 80;
s 300;
b 1020 80;
s 150;
b 1020 80;
s 300;

b 380 100;
s 300;
b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 420;

b 585 100;
s 450;

b 550 100;
s 420;

b 500 100;
s 360;

b 380 100;
s 300;
b 500 100;
s 300;
b 500 100;
s 150;
b 500 100;
s 300;

b 500 60;
s 150;
b 500 80;
s 300;
b 500 60;
s 350;
b 500 80;
s 150;
b 580 80;
s 350;
b 660 80;
s 150;
b 500 80;
s 300;
b 430 80;
s 150;
b 380 80;
s 600;

b 500 60;
s 150;
b 500 80;
s 300;
b 500 60;
s 350;
b 500 80;
s 150;
b 580 80;
s 150;
b 660 80;
s 550;

b 870 80;
s 325;
b 760 80;
s 600;

b 500 60;
s 150;
b 500 80;
s 300;
b 500 60;
s 350;
b 500 80;
s 150;
b 580 80;
s 350;
b 660 80;
s 150;
b 500 80;
s 300;
b 430 80;
s 150;
b 380 80;
s 600;

b 660 100;
s 150;
b 660 100;
s 300;
b 660 100;
s 300;
b 510 100;
s 100;
b 660 100;
s 300;
b 770 100;
s 550;
b 380 100;
s 575;

r/PowerShell • • Apr 26 '20

A fun little function to check if your password is in the haveibeenpwned database

124 Upvotes

I recently watched a computerphile about how people crack passwords using already leaked passwords from past breaches. He wrote a program in python to check passwords in the haveibeenpwned database, so I figured I would do the same for powershell. It is super basic as I didn't want to spend much time on it. Much more could be added like checking if the password is a certain length, has x, y or z. So really a skeleton of a more robust password security function, but I figured I would share it anyways. I don't really see the practical use of this function since I use password generators for complex passwords, but it is fun none the less.

Anyways here is the function

function Test-PasswordSecurity{
    param(
        [Parameter(Mandatory)]
        [securestring]$Password
    )
    $StringBuilder = New-Object System.Text.StringBuilder
    $Cred = [pscredential]::new("User",$Password)
    [System.Security.Cryptography.HashAlgorithm]::Create("SHA1").ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Cred.GetNetworkCredential().Password)) |
        foreach {[Void]$StringBuilder.Append($_.ToString("x2"))}
    $Hash = $StringBuilder.ToString()
    $First5 = $Hash.Substring(0,5)
    $Results = (Invoke-RestMethod -Uri "https://api.pwnedpasswords.com/range/$First5").split("`n") | foreach {
        [PSCustomObject]@{
            Hash = $First5 + $_.Split(':')[0]
            PasswordsFound = [int]($_.Split(':')[1])
        }
    }
    if ($Results.Hash -contains $Hash){
        $Count = ($Results | where Hash -eq $Hash).PasswordsFound
        Write-Warning "Password is inscure! Do not use this password! $Count Passwords found on pwnedpasswords!"
    }
    else{
        Write-Host "Password has never been seen before. Safe to use." -ForegroundColor Green
    }
}

r/PowerShell • • Dec 23 '19

Blog Post: PowerShell and Excel: Yes, They Work Together

124 Upvotes

Hey guys, I just wrote a shiny new blog post you may enjoy.

Summary: Marry PowerShell and Excel together by exporting and importing Excel workbooks, inspecting cells and more in this tutorial!

https://adamtheautomator.com/powershell-excel-tutorial/


r/PowerShell • • Jul 18 '19

Restore-RecoverableItems saved me

124 Upvotes

Got a request to apply retention to a 365 shared mailbox so emails permanently delete after 30 days. Accidentally applied as default tag(worst mistake of my IT career thus far) instead of personal Tag in 365 causing it to purge 40 mailboxes. When I called microsoft I asked for all options and they told me the only option is to run MFCMAPI.exe on the local machines to recover purged items which is very time consuming and doesnt recover everything back to normal you have to import the .pst. After talking to microsoft again (lvl2 support) with still no other options I moved forward with what they suggested. After recovering a couple mailboxes I encountered a MAC user which I couldnt use MFCMAPI for. My co-worker mentioned trying the exchange powershell and recoverable-items cmdlet just as a long shot. After running "Restore-RecoverableItems -indentity [email protected] -FilterItemTyple IPM.Note -sourcefolder PurgedItems -ResultSize Unlimited"I was able to restore all employees mailboxes back to normal quickly, in the background and maintain some credibility out of the circumstance. Powershell saved me


r/PowerShell • • May 07 '24

Information tip for readability apparently not many people know

123 Upvotes

if you use VS Code and generally your in favor of standard cmdlet naming and not having aliases in your code:

go into settings, search for "auto correct aliases" and tick the box.

Now, when youve written your script, right click into the editor and hit "format document" (shift+alt+f)


r/PowerShell • • Oct 09 '22

Script Sharing Replacing SMTP Basic Auth with Graph API is as easy as drag & drop replacement

123 Upvotes

Microsoft has now disabled basic auth for Office 365, with the minor exception of SMTP. While SMTP Basic Auth is not going away because of mostly legacy devices or applications, it's better to switch to oAuth 2.0 and Graph API as per Microsoft's recommendation.

The more significant issue is that Microsoft points you to Graph API documentation, specifically this link: https://learn.microsoft.com/en-us/graph/api/user-sendmail. If you want to upload attachments higher than 4MB, they send you to this link https://learn.microsoft.com/en-us/graph/outlook-large-attachments where after a brief moment, you decide to drop that idea and not send emails with larger attachments ;-)

Over one year ago, I wrote a PowerShell module called Mailozaurr, which simplifies sending emails with SMTP using BASIC Authentication, OAuth 2.0 and Graph API, or even SendGrid API. Last week I added functionality to send a that big attachment with Graph.

As Microsoft just disabled basic auth, I thought it would be a good idea to write a new blog post on how easy it is to replace Send-MailMessage with Send-EmailMessaage (part of the Mailozaurr module).

$Credential = ConvertTo-GraphCredential -ClientID $ClientID -ClientSecret $ClientSecret -DirectoryID $DirectoryID

# Sending email
Send-EmailMessage -From @{ Name = 'Przemysław Kłys'; Email = '[email protected]' } -To '[email protected]' `
    -Credential $Credential -HTML $Body -Subject 'This is another test email 1' -Graph -Verbose -Priority High

# sending an email with From as a string (it won't matter for Exchange )
Send-EmailMessage -From '[email protected]' -To '[email protected]' `
    -Credential $Credential -HTML $Body -Subject 'This is another test email 2' -Graph -Verbose -Priority Low

The only difference between using Standard SMTP and SMTP with Basic auth is renaming Send-MailMessage to Send-EmailMessage, adding a Graph switch, and changing SMTP Server, SMTP port to Graph API application which unfortunately requires some effort. But it's no longer necessary to play with what Microsoft offers as an alternative :-)

As part of the blog post, I'm also showing how you no longer have to use HTML/CSS to build nice-looking emails, and you can skip having to learn it, so it doesn't look ugly.


r/PowerShell • • Jun 28 '22

Information How to use Python to call the PowerShell engine without running the PowerShell executable

Thumbnail
devblogs.microsoft.com
123 Upvotes

r/PowerShell • • Sep 08 '21

Information Introduction to Powershell for pentesters

Thumbnail
youtu.be
123 Upvotes

r/PowerShell • • Feb 03 '21

Information FYI: Microsoft Ignite 2021 is coming up - March 2-4

123 Upvotes

Always some great PowerShell stuff, register at https://myignite.microsoft.com.


r/PowerShell • • May 24 '20

Script Sharing Fish-like prompt that autoshrinks your current directory listing (script in comments)

123 Upvotes

r/PowerShell • • Mar 27 '20

COV-ID-19 PowerShell Prompt

Thumbnail
powershell.co.at
123 Upvotes

r/PowerShell • • Aug 14 '19

PS 7.0 just got support for parallel execution in ForEach-Object cmdlet

123 Upvotes

Old way:

> Measure-Command {1..50 | ForEach-Object {Start-Sleep -Milliseconds (Get-Random -Minimum 100 -Maximum 200); $_}}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 8
Milliseconds      : 145
Ticks             : 81455266
TotalDays         : 9.42769282407407E-05
TotalHours        : 0.00226264627777778
TotalMinutes      : 0.135758776666667
TotalSeconds      : 8.1455266
TotalMilliseconds : 8145.5266

Vs new way:

> Measure-Command {1..50 | ForEach-Object -Parallel {Start-Sleep -Milliseconds (Get-Random -Minimum 100 -Maximum 200); $_}}
                                                                                                                           
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 2
Milliseconds      : 94
Ticks             : 20947062
TotalDays         : 2.42442847222222E-05
TotalHours        : 0.000581862833333333
TotalMinutes      : 0.03491177
TotalSeconds      : 2.0947062
TotalMilliseconds : 2094.7062

Edit: /u/sup3rlativ3 and /u/Analytiks made valid concern regarding the sleep randomness spoiling the command execution time so I have made following example that should satisfy all nerds around here ;)

Sequential pipeline execution:

> (Measure-Command {1..50 | ForEach-Object {Start-Sleep -Milliseconds 100; $_}}).TotalMilliseconds
5463.9569

Parallel pipeline execution:

> (Measure-Command {1..50 | ForEach-Object -Parallel {Start-Sleep -Milliseconds 100; $_}}).TotalMilliseconds
1352.9661

r/PowerShell • • Jul 20 '19

How to build a PowerShell menu

Thumbnail
adamtheautomator.com
123 Upvotes

r/PowerShell • • Nov 06 '20

Script Sharing Win10Debloat - Remove bloatware, disable bing in windows search & declutter windows 10

122 Upvotes

Hey Everyone!

For a while now I've been working on a script to quickly setup my new windows 10 installations, and I thought why not share it! Although there are many tools that promise'debloat' windows, i didn't really want to install any applications to do it. Not to mention the fact that some of those tools are not open source, and can be incredibly overwhelming and extensive to the point where most people would be put off by it.

Although you can customize what tweaks you want the script to make, with the default settings it will:

  • Remove all apps from this list. (Everything can be reinstalled from the microsoft store)

  • Hide the 3D objects folder under 'This pc' in windows explorer.

  • Disable bing in windows search.

  • Disable tips & tricks on the lockscreen. (This changes your lockscreen wallpaper to the windows default)

  • Disable tips, tricks and suggestions in the startmenu and settings.

  • Disable the 'Include in library' from context menu.

  • Disable the 'Give access to' from context menu.

  • Disable the 'Share' from context menu.

It's possible to do a customize exactly which changes you want the script to make, or you can go for the default, which should work just fine for most people. If you want to revert any of the changes you can use the included registry files and removed applications can be reinstalled from the microsoft store.

The script is available on github: https://github.com/Raphire/Win10Debloat, where you will also find a more detailed description of what my script can do. I would also like to encourage everyone to look through the script before using it!


r/PowerShell • • Jun 16 '20

Information Windows Terminal Deep Dive: Customizing the Windows Shell with Justin Grote

122 Upvotes

Hello PowerShell peeps!
I apologize for the late notice on this meeting.... but please feel free to join us; it should be another awesome topic and demo!

Join us this Wednesday evening for a deep dive into the Windows Terminal! Learn all the slick customizations and tricks that are possible. See the link below for details!

https://www.meetup.com/Research-Triangle-PowerShell-Users-Group/events/271064741/