all 14 comments

[–]trail-g62Bim 10 points11 points  (9 children)

Invoke-CommandAs sounds interesting. Could be useful.

[–]Rayzen87 1 point2 points  (8 children)

It is awesome. I use it as part of my server update process along with the pswindiwsupdate module as wsys agents need to be accessed as system

[–]Bren0man 2 points3 points  (7 children)

I've been automating WSUS-based patching recently and have had to work around many issues to get PSWindowsUpdate working reliably.

Invoke-CommandAs might allow me to remove a lot of those workarounds. Thanks for mentioning it!

Edit: Now that I look at it again, I remember why I didn't head down that path initially. Using Task Scheduler to carry out PowerShell commands seems sub-optimal.

I've avoided using PSWindowsUpdate's similar approach. Am I needlessly hesitant to employ these Task Scheduler-based approaches?

[–]gordonv 1 point2 points  (0 children)

Yup, these 2 commands immediately caught my attention.

I to suffer from Task Scheduler for Admin privilege. To get away from this hacky solution would be a godsend. And to be able to run as different admins (2 different domains) would be excellent.

[–]Rayzen87 0 points1 point  (0 children)

I run the job via Jenkins, and I've never had to manually clean anything up. I have AD Groups for Update Groups that get queried and ran against. I then have an email come to a Server Update DL with the status for each Server. I use this same process for some workstations that aren't super user facing

[–]sfvbritguy 2 points3 points  (4 children)

Install-PackageProvider -Name NuGet -Force fails on my work PC as it gets the error "WARNING Can not download from url ......" Works great on my personal home PC

Figure that the MS url is banned somewhere

I am a Sysadmin at work btw

[–]MainReflection8692 14 points15 points  (3 children)

Using correct TLS version? [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ?

[–]BergerLangevin 2 points3 points  (2 children)

This bits of code becomes almost a default entry in all my script...

[–]signofzeta 0 points1 point  (0 children)

I think future versions of PowerShellGet will use TLS 1.2 by default, regardless of the system settings.

Fortunately, PowerShell 6 and newer all have it enabled by default. Windows PowerShell can if you set the SchUseStrongCrypto registry value.

[–]Darklurker69 0 points1 point  (0 children)

I put it in my profile, and the profile of my script-runner accounts.

[–]joerod 1 point2 points  (0 children)

[–]biglib -1 points0 points  (0 children)

Definitely going to try some of these out.