Scripts

This section of my blog will feature the scripts I have published for the community to use and to improve upon. I created this section as a celebration and a thanks to everyone who has been using my scripts and asking me all the hard questions that challenged me to improve my scripts time after time again.

 

My repositories

PowerShell Gallery
GitHub
TechNet Script Gallery

 

TechNet Script Gallery Contributions

Add AD User/Group to Local Administrator Group Q and A
The script can use either a plain text file containing a list of computername or a computer name as input and will add the trustee (AD user or group) as an administrator to the specified computer(s). The script will report back errors if the account is already a member. Updated 2013-7-23
Released 2012-11-2
24,955 Downloads
Compare group membership of two users and add target user to groups Q and A
The goal of this script is to grant the destination user all the missing memberships when compared to the source user. Any missing memberships will be added by this script while outputting the changes to the console.This script compares the group membership of two AD users. Updated 2013-8-13
Released 2012-3-14
2,231 Downloads
Connect-Mstsc – Open RDP Session with credentials Q and A
This script allows you to open a Remote Desktop session with a remote session while specifying credentials. This functionality was removed from the mstsc.exe application and this PowerShell function can serve as a workaround that allows you to automatically connect to servers. Updated 2015-4-9
Released 2013-2-14
11,485 Downloads
Connect-Mstsc – Open RDP Session with credentials (PowerShell 2.0) Q and A
This script allows you to open a Remote Desktop session with a remote session while specifying credentials. This functionality was removed from the mstsc.exe application and this PowerShell function can serve as a workaround that allows you to automatically connect to servers. Updated 2015-4-9
Released 2015-4-9
453 Downloads
Convert-CsvToXlsx – Function to Convert Csv to Xlsx Q and A
This script provides the ability to convert csv files to xlsx files via the pipe line or by specifying the file. This function works by using the Excel.Application object, specifically the SaveAs method to store the file in a different format. Updated 2015-6-11
Released 2015-6-11
80 Downloads
Credential in Clipboard – Store and Retrieve credentials in the clipboard Q and A
The two functions in the CredInClip script are used to both securely store and retrieve credentials by utilizing the clipboard. This can be used to transfer credentials over multiple PowerShell sessions without the need for re-entering the passwords manually. Updated 2015-6-26
Released 2015-6-25
47 Downloads
Delete files older than x-days – Cleanup Script Q and A
Script to delete files older than x-days. The script is built to be used as a scheduled task, it automatically generates a log file based on the copy location and the current date/time. There are various levels of logging available. Updated 2013-9-26
Released 2012-3-5
51,345 Downloads
Disconnect-LoggedOnUser – Disconnect a RDP session remotely Q and A
My Get-LoggedOnUser script is available here: Get-LoggedOnUserThis function provides the functionality to disconnect a RDP session remotely by providing the ComputerName and the SessionId. It is build to work either as a stand alone function to disconnect RDP sessions remotely. Updated 2015-6-3
Released 2015-6-3
181 Downloads
Folder Compare Move Same Files Q and A
Script to move files if the same file is found in folder1 and folder2. It recursively goes through both folders and compares the base filename, filename without extension, of each file in the first folder. If a match is found both files are moved to a third folder, the destination folder. Updated 2012-3-15
Released 2012-2-24
870 Downloads
Function to get file and folder names with long paths Q and A
This function requires Robocopy to be installed. Robocopy is used to recursively search through a folder structure to find file or folder names that have more than a certain number of characters. The function returns an object with three properties: FullPath,Type and FullPath. Updated 2013-8-28
Released 2012-7-23
6,195 Downloads
Get scheduled tasks from remote computer Q and A
This script uses the Schedule.Service COM-object to query the local or a remote computer in order to gather a formatted list including the Author, UserId and description of the task. This information is parsed from the XML attributed to provide a more human readable format. Updated 2015-3-26
Released 2012-5-23
12,385 Downloads
Get-ComObject Function to get a list of available ComObjects Q and A
This function has two parameter sets, it can either return all ComObject or a sub-section by the filter parameter. This information is gathered from the HKLM:\Software\Classes container.This script contains a function, be sure to load the function before using it. Updated 2013-6-24
Released 2013-6-24
1080 Downloads
Get-ExtensionAttribute – Retrieves extension attributes from files and folders Q and A
Retrieves extension attributes from files or folders. Uses the dynamically generated parameter -ExtensionAttribute to select one or multiple extension attributes and display the attribute(s) along with the FullName attribute. Updated 2015-3-30
Released 2015-3-30
140 Downloads
Get-GroupPolicyObject : Query AD to get Group Policy objects Q and A
This script uses the DirectoryServices.DirectorySearcher object to get all or a selection of Group Policy Objects. Because the DirectoryService DirectorySearcher objects is use the Active Directory module is not required and the script has no dependency on external modules. Updated 2013-7-30
Released 2013-7-30
1,140 Downloads
Get-LocalLastLogonTime – Get the LastLogin time on a local system Q and A
This script utilizes the WinNT provider to connect to either a local or remote system to establish if and when a user account last logged on that system. The output of the script is the computername, username, lastlogin and error messages if there are any. Updated 2015-6-1
Released 2015-6-1
118 Downloads
Get-LoggedOnUser Gathers info of logged on users on remote systems Q and A
This script utilizes quser to query either the local or remote system and parses this into PowerShell objects using the ConvertFrom-Csv Cmdlet. It supports pipeline input or an array of computers in the ComputerName parameter. Updated 2015-6-3
Released 2013-6-25
6,365 Downloads
Get-MappedDrive – Get list of locally mapped network drives Q and A
This function requires PowerShell 2.0 and utilizes the Wscript.Network COM object to enumerate the locally mapped network drives. The output of the Wscipt.Network COM object is a collection of strings. This function takes those strings and converts it into objects. Updated 2014-7-22
Released 2014-7-22
494 Downloads
Get-OUWithGPOLink – List FriendlyGPODisplayName for each OU Q and A
This function requires PowerShell v2 with the ActiveDirectory module. This function is written as an extensions to the functionality of Get-ADOrganizationUnit and adds an additional property ‘FriendlyGPODisplayName’ which can be used to identify which GPOs are attached to an OU Updated 2014-7-20
Released 2014-7-20
576 Downloads
Get-RecycleBin – shows the contents of the Recycle Bin Q and A
This function is intended to compliment the Clear-RecycleBin cmdlet, which does not provide any functionality to view the files that are stored in the Recycle-Bin. Updated 2015-9-24
Released 2015-9-24
2 Downloads
Get-RemoteProgram Get list of programs on remote or local computer Q and A
This script generates a list by querying the registry and returning the installed programs of a local or remote computer. It allows for retrieval of additional properties such as the uninstall string of an application as well. Updated 2015-4-23
Released 2013-8-23
22,034 Downloads
GUI – Compare group membership of two users and update user Q and A
The goal of this script is to grant the destination user all the missing memberships when compared to the source user. Any missing memberships will be added by this script and and any additional memberships will be removed. Updated 2015-3-9
Released 2012-5-9
1,557 Downloads
Invoke-BossMode – Eliminate distractions from your desktop Q and A
This script provides the ability to temporarily show or hide a number of applications. The windows can be set to reappear by pressing enter, a time-out or a hidden string that should be entered in the correct order. Updated 2015-5-29
Released 2015-5-28
78 Downloads
Invoke-BossMode – Eliminate distractions from your desktop (PowerShell 2.0) Q and A
This script provides the ability to temporarily show or hide a number of applications. The windows can be set to reappear by pressing enter, a time-out or a hidden string that should be entered in the correct order. Updated 2015-5-29
Released 2015-5-29
46 Downloads
PowerShell function to runas a different user Q and A
Script grab or sets password to and from file. Using this method this allows to emulate the runas command and you are able to run commands in PowerShell with -credential without having to type a password.
This allows for automation of tasks were multiple accounts are required.
Updated 2012-11-29
Released 2012-3-22
8,101 Downloads
Quantum Random Number Generator, in PowerShell Q and A
Sub-atomic particles appearing and disappearing measured by extremely sensitive light sensors are generating these random numbers. According to Quantum Theory these events are completely random and connect be predicted. Updated 2012-4-18
Released 2012-4-18
243 Downloads
Query for AD Users that have not changed password for x-days Q and A
This script will return the samaccountname, pwdlastset and if an account is currently enabled or disabled. This script is part of the Active Directory Friday section of my blog. Updated 2013-7-26
Released 2013-7-26
2,031 Downloads
Remove Scheduled Tasks from remote computer Q and A
This script uses the Schedule.Service COM-object to connect to the local or a remote computer in order to remove scheduled tasks programmatically. This script is created to work in combination with my Get-ScheduledTask script, but also works as a standalone function. Updated 2015-8-7
Released 2015-8-7
41 Downloads
Script that retrieves disk information from list of computer and output to csv Q and A
This script reads a list of servers or computer from a plaintext file and read the disk information using WMI. This information will be written to a comma-separated file which automatically appends the current date & time so this script can be run as a scheduled task.  Updated 2012-3-23
 Released 2012-3-23
 1,013 Downloads
Script to check file properties Q and A
This script grabs a list of server names from a text file and pings those machines. It then searches for a file on the computers listed in the input file and writes the machinename, filename, filesize, file/productversion and last write time to a .csv. Log file is auto-generated Updated 2012-6-19
Released 2012-2-15
1,435 Downloads
Script to display the Windows Firewall Rules Q and A
This script will gather the Windows Firewall rules from the registry and convert the information stored in the registry keys to PowerShell Custom Objects to enable easier manipulation and filtering based on this data.  Updated 2013-6-11
 Released 2013-1-9
 1,575 Downloads
Script to get orphaned home folders and folder size Q and A
This script queries AD with the name of the home folder. If this query does not result in an account or a disabled account the script will list the folder size with the folder path and error message.  Updated 2015-4-21
 Released 2012-10-19
 3,176 Downloads
Search-Msdn, a function that queries Msdn and opens results in browser Q and A
This function takes a searchquery, either a single query or an array and culture value to query MSDN and opens a webpage in the default browser.  Updated 2013-6-23
 Released 2013-6-23
 709 Downloads
Test-ComputerName, verify ping and rdp connectivity for a computer Q and A
This function pings and opens a connection to the default RDP port to verify connectivity, futhermore it will check if a DNS entry exists and whether there is a computeraccount in Active Directory. Updated 2013-8-23
Released 2013-8-23
2,885 Downloads
Test-ScheduledTaskFolder Q and A
This script uses the Schedule.Service COM-object to query the local or a remote computer in order to test if a certain scheduled task folder exists. Updated 2015-3-30
Released 2015-3-30
84 Downloads
VBscript – Network Driver information Q and A
This script runs either locally or remotely as specified by the strComputer variable at the start of the script. The value can be changed by launching the script using either cscript / wscript eg:cscript QueryWMIforNetworkDriverInfo.vbs computer1 : Will run query against computer Updated 2012-2-22
Released 2012-2-22
1,225 Downloads
Verify the Active Directory credentials of a user account Q and A
This PowerShell function takes a user name and a password as input and will verify if the combination is correct. The function returns a boolean based on the result. Updated 2013-5-10
Released 2013-5-10
2,860 Downloads
Verify the Local User account credentials Q and A
This PowerShell function takes a user name and a password as input and will verify if the combination is correct. The function returns a boolean based on the result. A computername can be specified to check account details on remote systems. Updated 2013-5-20
Released 2013-5-20
1,926 Downloads
Share

8 thoughts on “Scripts

  1. Pingback: 150000 Downloads: A personal milestone | Jaap Brasser's Blog

  2. Rajesh Lohana

    How can i monitor what applications installed on all workstations in our domain network

    I want to get list of all applications installed on all workstations remotely

    Reply
    1. Jaap Brasser Post author

      For a one off job or as a scheduled job you could use the Get-RemoteProgram script. If you combine this with the Get-ADComputer Cmdlet you should be able to retrieve the computer names of all workstations and query for the programs they have installed.

      Reply
  3. Pingback: Customize Windows 10 Module | Jaap Brasser's Blog

  4. Pingback: Get-ZipFileProperties function | Jaap Brasser's Blog

  5. Ken

    Hello Jaap!
    Thank you for sharing all that you do!! Within your Get-RemoteProgram script last updated 2016-8-26, I am curious about a few details on how the -ExcludeSimilar -SimilarWord process is working. I have ran it against a Windows 7 32-bit OS machine that has several lines of Microsoft SQL Server 2012 / Data / Compact (8 instances of 2012, and 2 each for the others). Being fairly new, I changed the value in your script at the ForEach area to try to reduce the output results.
    A bit more specifically, I changed the {3} that follows to 2, 4, and 5 with no difference in outputs:
    } else {
    $Regex = [regex]”(^(.+?\s){3}).*$|(.*)”

    Is there a proper way to change this that will make a difference?

    Thank you in advance for any advice!
    Ken L

    Reply

Leave a Reply

Your email address will not be published.