Custom Operating System PowerShell Module

 

A while ago I created PowerShell Module which helps me with my every day work. This one is not “a rocket science” but it still might be helpful to someone. But stay tuned since things will be added in near future. This are currently available“CMDlet-s”:

Get-MyOSVersion
Get-MyOSArchitecture
Test-MyLDAPuser
Install-MyDotNET35
Get-MyPerfToPID

To Start Using this CMDlets Download it and then browse with powershell to folder where MyOScmdlets.psm1 resides then type:
Import-Module .\MyOScmdlets.psm1

OK now lets go into the details of functions..

Get-MyOSVersion
This CMDlet returns Operating system. For example:
Microsoft Windows 8.1 Enterprise

Get-MyOSArchitecture
This one returns OS Architecture. For example:
64-bit

Test-MyLDAPuser
This CMDlet test if LDAP is working for a user. To use it type Test-MyLDAPuser in PowerShell and hit enter. You will get a window to enter user name and password. Enter credentials for let say for account which will be used for printer AD queering and you will get an output like this:

LDAP information for user: dummy.user1
—————————————————

LDAP Path
———

LDAP://CN=DummyUser1,OU=Users,OU=Basel,OU=Switzerland,OU=SomeOU,DC=contoso,DC=com

User Info
———

DistinguishedName : CN=DummyUser1,OU=Users,OU=Basel,OU=Switzerland,OU=SomeOU,DC=contoso,DC=com
Enabled           : True
GivenName         : Dummy
Name              : Dummy User1
ObjectClass       : user
ObjectGUID        : ed822d96-ed53-4715-8708-d3f0e24536ff
SamAccountName    : dummy.user1
SID               : S-1-5-21-1004336348-1177238915-682003330-512
Surname           : User1
UserPrincipalName : dummy.user1@contoso.com
Authentication Test:
——————–

Authentication for user: dummy.user1 Successful?
True

Install-MyDotNET35
This Functions Checks if .NET 3.5 is installed on local or remote system. Please note that installation currently works only for 2008 Servers. For 2012 all it does is to check if installed.

To use it locally run: Install-MyDotNET35
To use it on remote server run: Install-MyDotNET35 -ComputerName Server01

Get-MyPerfToPID
This function returns PID of a process along with Process name visible in Performance monitor.

To use it you could run for example:  Get-MyPerfToPID | where { $_.ProcessNamePerf -match “svch” } | ft -AutoSize

And the output would be something like this:
ProcessNamePerf  PID
—————            —
svchost#2                 902
svchost#1                  771
svchost                      722

Oh and one more thing. Names of “cmdlets are not by the book. I always ad “My” in between: for example Test-MyLDAPuser so I can select them faster and also to differentiate my Cmdlets from built in ones.

This is it for now
Jure

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Custom Operating System PowerShell Module

  1. Pingback: Match Performance Monitor Processes Instance to PID | Rather Serious SCOM Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s