Three years ago, I posted CombineXLSheets.vbs, a vbScript which allows you to drop and drag Excel spreadsheets onto it and have them combined into a single workbook file with multiple worksheets. Now that I am working in PowerShell, I have found the need to consolidate CSV files. Parts of Combine-CSVFilesToWorksheets.ps1 come from code ported from…
Consolidating Data For Report: Getting from Group-Object to CSV
I am working on some scripts which show AD domain controllers by their site. My goal was to have the data combined so that each site has a single row, with the server name and IP address for each site being shown joined by semi-colons. None of the examples for…
Export to XLSX without Excel: Export-XLSX.ps1 Revisited and Tweaked
I often look at the code of others with respect and admiration. Peter Kriegel (Germany) wrote Export-XLSX.ps1, an amazing script which lets you export data into a real XLSX file without Excel being installed. The script also enables you to directly append worksheets to XLXS files. His website, http://www.admin-source.de, hasn’t been updated in a while,…
Get the NetBIOS AD Domain Name from the FQDN
I hate using NameTranslate, because it is a COM object, and because the output is often really hard to get into a clean, trimmed string. The netBIOS name isn’t a part of the AD domain object, but I suspected that the information could be gotten using a LDAP query. My searching lead me to a post…
Convert System.DirectoryServices.SearchResult to a PSObject
The ADSI accelerator is fast, and built into PowerShell, unlike the Active Directory Module. When use it, or the ADSISearcher, you have results which look like this [Image from previous Microsoft URL]: Getting the properties out to a file can be tricky. I wrote two little functions to make this easier: Function ConvertTo-PSObjectFromDirectorySearchResult($oDS){ $outval =…
Get COM Object Constants with PowerShell
I avoid using COM objects whenever I can. One of the annoyances is that you need to look up the value of constants. Shay Levy, in http://www.powershellmagazine.com/2013/03/20/pstip-working-with-excel-constants/ has a script which demonstrates how to enumerate the constants for the Excel COM object. Get-COMConstants.ps1, is an advanced function generalization, which can be used for any COM…
Test Replication – A PowerShell Wrapper for RepAdmin
Repadmin is a standard tool in an AD admin’s toolbox, and “showrepl” displays the status of replication in your domain. The results of this command are quite verbose, and can make your eyes glaze over in late night troubleshooting. A number of people have noticed that you can pipe RepAdmin CSV output to the ConvertFrom-CSV…
Remove DNS Host Record and PTR with PowerShell
You have been asked, “Please remove the host record for these 15 computers, plus their associated PTR records”. It isn’t a difficult task, but it can be time consuming, especially if you have a large DNS database. The in-addr.arpa bit can be annoying to do over and over again. When I first decided to automate…
Who Added this User to the Domain?
On of the questions that I am frequently asked is “who created that user”. In a small shop, the answer should be “me”. But in a really large environment the answer may not be quite so clear. When an object is created in Active Directory, the owner of the object is the creator of the…
My Windows 10 Fix
I had some issues with my Windows 10 computer at home. I did some research, and came up with this batch file to freshen and check all of the operating system files. Save this as Fix10.cmd (or Fix10.bat) and run it with admin rights. @echo off REM Fix10.cmd REM Alan Kaplan www.akaplan.com/blog REM This batch…