Alan's Blog

"Yeah. I wrote a script that will do that."

Menu
  • About My Blog
Menu

Get AD Schema Attribute Names

Posted on December 2, 2018 by Alan

One of our admins was running my export and import permissions script, and I thought he had made an error when I looked at an ExtensionAttribute name.  Nope.  The difference was between the attribute name and the LDAP display name which you see in the Attribute Editor tab from the advanced view of Active Directory…

Read more

Convert CSV to Excel with Drag and Drop

Posted on September 16, 2018August 11, 2019 by Alan

Back in 2009, I published Convert CSV files to Excel, a vbscript which converts csv files to xlsx format.  Although there is not good way to directly support drag and drop with PowerShell, it can be done with a form.  Convert-DroppedCSVsToExcel.ps1 was mostly written as an exercise for me to work with drag and drop…

Read more

Get User Lockout Status with PowerShell

Posted on September 15, 2018September 15, 2018 by Alan

Get-UserLockoutStatus.ps1 is an interactive script to get the lockout status of a selected user or all users in a specified domain.  It queries each domain controller for non-replicated attributes using a workflow with an inline script for speed.  It requires the ActiveDirectory Module.

Read more

Is that String a Date?

Posted on September 2, 2018 by Alan

Test-IsDate is a simple function which tests a string to determine whether it is a date. function Test-IsDate([string]$sDate) { [boolean]($sDate -as [DateTime]) } Test-IsDate ‘Monday, August 13, 2018 1:28:48 PM’ returns True.

Read more

Create a Hash Table with AD Domain DNS Root and NetBIOS Names

Posted on September 2, 2018 by Alan

I frequently get requests to modify or lookup a list of user names in a CSV file where the username is NTDomain\SamAccountName.   Get-ADUser will let you use the NT domain as a server name, but in my experience it is slower than using the domain’s FQDN.  Before I import the list in my code, I…

Read more

Listing (and running) OS Shell Commands with PowerShell

Posted on September 2, 2018 by Alan

I think I started using Shell commands when I went looking for the startup folder in Windows 8.  A post from Jasone’s  MSDN blog suggested the easiest way to open it was by typing “Shell:Startup” in from the run box (WIN+R).  I became curious about how to enumerate a list of these shortcuts, and how…

Read more

Identify an AD object from the SID

Posted on September 2, 2018September 2, 2018 by Alan

Convert-SidToADObject will take an AD SID and return an object containing the object’s name, SamAccountName, Description, type and distinguished name. function Convert-SidToADObject($sid) { $u = [adsi](“LDAP://<SID=” + $sid + “>”) if ($u.SamAccountName) { [psCustomObject]@{ Name = $u.Name.value SamAccountName = $u.samAccountName.value Description = $u.description.value Type = $u.objectclass.Value[1] DistinguishedName = $u.distinguishedName.value } } Else { “Lookup Failed”…

Read more

Practical Lessons on WPF Forms and PowerShell

Posted on March 4, 2018March 4, 2018 by Alan

Last weekend I decided that I was finally going to figure out how to stop using Windows Forms, and move to the newer Windows Presentation Foundation (WPF).  Some time ago, I had read a WPF blog post from FoxDeploy.com, which shows how you can cut and past code from Windows Visual Studio into their code…

Read more

Where am I? Getting the Name of the Currently Executing Function

Posted on March 3, 2018 by Alan

I almost always debug scripts by stepping through them.  But sometimes it is nice to just have a way to write the current function during execution.   I use this: write-verbose “In function {0} ” -f $MyInvocation.MyCommand This uses the .NET formatting style, where the contents of the item after -f is placed as a…

Read more

Two Ways to Get Mapped Drives with WMI

Posted on March 3, 2018 by Alan

For years I have been getting mapped drives from WMI using Win32_NetworkConnection. Typical code looks like this in PowerShell: Get-CimInstance -ClassName ‘Win32_NetworkConnection’ | Select LocalName, RemotePath I have been using a product called ExpanDrive to map my cloud storage to drive letters.  When I tried to view the drives with Win32_NetworkConnection, I had no results….

Read more
  • Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • …
  • 42
  • Next

Search

Please Note

All the scripts are saved as .txt files. Newer files have a “View Script” button which will let you save or open a script in notepad. For earlier posts, the easiest way to download with IE is to right click on the link and use “Save Target As”. Rename file from Name_ext.txt to Name.ext.

To see a full post after searching, please click on the title.

PowerShell Scripts were written with version 3 or later.

https connections are supported.

All new users accounts must be approved, as are comments. Please be patient.  If you find a post error or a script which doesn’t work as expected, I appreciate being notified.  My email is my first name at the domain name, and you are welcome to contact me that way.

Tags

1E ACLS Active Directory ActiveDirectory ADSI Advanced Functions Audit Change Administrator Password COMObject Computer Groups DateTime Desktop DNS Excel FileScriptingObject Forms General GPO GPS Group Policy Hacks ISE Lockout logons NAV740 Nessus OU OU permissions Outlook Pick Folder Power PowerShell Powershell Scriptlets RDP SCCM schedule reboot Scripting Security Shell.Application user information VBA Windows Update WMI WordPress WPF

Categories

akaplan.com

  • Back to Home Page

Archives

Scripting Sites

  • A Big Pile of Small Things
  • Adam, the Automator
  • Art of the DBA
  • Ashley McGlone
  • Boe Prox
  • Carlo Mancini
  • DexterPOSH
  • Doug Finke
  • Jaap Brasser's Blog
  • JeffOps The Scripting Dutchman
  • Jonathan Medd's Blog
  • Keith Hill's Blog
  • LazyWinAdmin
  • Nana Lakshmanan
  • PowerShell Magazine
  • PowerShell Team Blog
  • PowerShell.org
  • PwrShell.net
  • Richard Siddaway's Blog
  • Ryan Yates' Blog
  • Skatterbrainz
  • The Lonely Administrator

SQL Site

  • Art of the DBA

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2025 Alan's Blog | Theme by SuperbThemes

Terms and Conditions - Privacy Policy