Here’s a script I’ve put together that will retrieve the current user sessions from a remote host using psexec.exe. Then, it executes a scriptblock using the current user session context. Simple, but very powerful. I would suggest not running this in an enterprise environment if you would like to stay in your security team’s good…
Category: Windows Administration
Posts pertaining to performance of administrative tasks in Windows operating systems
ConfigMan – Teams – Disable Teams Autorun with PowerShell
Teams’ default behavior is to launch automatically upon user login. This can be undesirable for a myriad of reasons, and can be managed with Group Policy with a couple of caveats. The first is that this policy is a User configuration policy, and not a Computer configuration policy. The second is that the policy must…
PowerShell – ConfigMan – Convert OUs to Collections
With ConfigMan application deployments, it’s good practice to, when applicable, divide large groups up and take a staged approach at deployment. I’ve found myself multiple times creating multiple collections containing the objects within an Active Directory (AD) Organizational Unit (OU) for staged deployments. I decided to build a script to ease this process. This script…
PowerShell – Active Directory – Convert AD Name Formats
Many of the ActiveDirectory PowerShell module cmdlets expect the distinguished name format. I find this somewhat inconvenient, as this format does not read as nicely as the canonical name format that so many of us have become familiar with. Additionally, an objects’ canonical name is somewhat more readily available via the Active Directory Users and…
PowerShell – AD Cleanup – Get Extraneous Group Membership
If you have an Organizational Unit (OU) in Active Directory (AD) containing a large number of users, and you need to ensure these users are not members of any other groups, or perhaps that they are only members of certain groups, I’ve put a PowerShell script together for this purpose. It allowed me to quickly…
Azure – Fixing AAD Connect Sync Not Starting Post-Reboot
Some months ago, a problem was noticed with one of our servers that hosts the Azure AD Connect Sync service. After a reboot, the service did not automatically start back up as expected; and, upon further inspection, the synchronization from Azure > on-prem domain was not functional. In troubleshooting this issue, I took to the…
PowerShell – Extract Text From .PDF Files
A unique challenge presented itself the other day- to extract text from .PDF files. I found the iText-based PSwritePDF module in the PowerShell Gallery that offers this capability; however, I found it to be an incomplete solution due to the fact that many .PDF files (particularly those created with an automated tool, like GhostScript or…
PowerShell – Get Uninstall String Info from Registry
I’ve put together a simple function to extract the Uninstall String information from the Windows Registry. This is convenient for identifying the binary location and arguments to uninstall a given win32 application. Or, if the application was installed with a .msi file, the product code will often be specified – which, of course, can be…
PowerShell – Get Additional Application Info
The common method used to return win32 application information from a Windows device via PowerShell is ‘gwmi win32_product.’ This returns the more pertinent IdentifyingNumber, Name, Vendor, Version, and Caption properties, as shown in the below example output. However, Windows does have more information on these applications. Using the ‘wmic product get’ command, we can get…
PowerShell – Get AD User’s Last Logon Time
Here’s a simple little function I put together that will accept a user’s name in First Last format, and then return their last logon time information from AD. Here is the GitHub link: https://github.com/p8nflnt/SysAdmin-Toolbox/blob/main/Get-AdUserLogonTime.ps1