r/PowerShell • • Nov 08 '21

Script Sharing I did a thing! (Windows Admin Module/Repo)

I was able to finally get all of my go to Windows/AD Ops Scripts into a github repo to share with the community.

History

A few years ago I took the challenge to perform all daily duties from a remote shell. Everytime that I (or a teammate) had to logon via RDP to look at something, we added that scenario to a backlog and slowly added to the list. Some commands are actually wrappers for regular cmd commands (netstat, tasksch, etc.).

Behind the Scenes

I've worked with and created modules before, but I've never pushed one to the powershellgallery. My github repo is setup to Run PSScriptAnalyzer against any commit and upon the creation of a release, it will publish the module to powershellgallery.

Useful/Interesting Commands

Get-List - Paste a list into your shell, instead of having to call a .txt file. Easily my most used command working with lists of servers or users all the time.

Get-Table - Paste a table from excel into your shell and store as a pscustomobject.

Compare-Servers - Useful for troubleshooting why something works on one server and not the other.

Get-GPResult - Get an RSOP report from a remote machine even if you've never logged on to it.

Get-PortCertificate - stolen from someone else but useful for identifying machines where you only have an IP and no reverse DNS record.

Get-Htop - Get performance info via graph for remote machines.

Get-SChannelInfo - Useful for hunting down the info that IISCrypto will give you.

Room for improvement

  • No help files yet.... will get there.

  • Missing a few commands that I need to hunt down... Compare-ADUser, etc.

Links

Github Repo

PowerShell Gallery Package

115 Upvotes

14 comments sorted by

4

u/powershellnut Nov 08 '21

Very nice work. A lot of useful commands for people to use or reference. I do have a question though, many of these functions use the $Using scope modifier along with Invoke-Command. When the functions target the local computer, then Invoke-Command runs the script block as a child scope of the current scope which then causes an error related to the $Using statement. Do you not run into these errors? Using the -ArguementList parameter of Invoke-Command would avoid these type of errors. There are few other things, but I do not want to pick apart your achievement because overall these functions look great.

4

u/spartymcfarty Nov 08 '21

Excellent suggestions! Some of these are rough modifications glad you caught the scoping. Typically would run from a laptop/jump box and would never need reference of localhost. Buuuuuuuutt now that i'm sharing with the world, will probably need to refactor.

2

u/powershellnut Nov 08 '21

Overall great work and thanks for sharing with the community!

4

u/MyOtherSide1984 Nov 08 '21

I've never worked on a core or strictly terminal machine, but if you have your list for "get-list" in your clipboard, you can just do $X = clip and it will grab your entire clipboard as an array

2

u/spartymcfarty Nov 09 '21

Bravo! I love tricks like this.

3

u/Sleazified Nov 08 '21

compare-servers are not working for me, it says its not recognized as a name of a cmdlet, even after install-module WinOps is executed

2

u/spartymcfarty Nov 08 '21

Silly question: After you ran 'install-module winops' did you also run 'import-module winops'?

1

u/Sleazified Nov 08 '21

Yeah i did that. but it also says:

"The 'New-TimeSpan' command was found in the module 'Microsoft.PowerShell.Utility', but the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.
Utility'."

but i cant seem to find a solution to this, i tried removing the ps ultility module and reinstall it with the same results

1

u/Sleazified Nov 08 '21

Hmm, i just tried in our test domain, and there it works.

Makes me wonder why it wouldent work in our productions envirment.

8

u/EIGRP_OH Nov 08 '21

Nice work! Looks great.

4

u/Owasa Nov 08 '21

Thank you for sharing this!

2

u/[deleted] Nov 08 '21

Great Job!

2

u/AndyGrundt Nov 08 '21

Really nice work!