Alan's Blog

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

Menu
  • About My Blog
Menu

Author: Alan

See https://www.akaplan.com/about/

Is this string an IP?

Posted on November 30, 2013 by Alan

PowerShell one liner to test whether a string is a valid IP address: Function IsIP ($strTest){[Net.IPAddress]::TryParse($strTest,[ref]$null)} This works for both IPv4 and IPv6.  

Read more

Prompt User to Dot Source an Advanced Function

Posted on November 26, 2013December 25, 2013 by Alan

I have found that users complain that some of my advanced functions appear to do nothing when run.  I wrote the following bit to prompt them how to dot source a script: If (($args.Count -eq 0) -and (!($ScriptVar))) { $ScriptName = $MyInvocation.MyCommand.Name.Replace(".ps1","") $commandline = $MyInvocation.InvocationName.trim() if ($commandLine -ne "."){ $myFile = $MyInvocation.MyCommand.Definition.ToString() Write-warning "This script…

Read more

Enhanced Mitigation Experience Toolkit (EMET) 4.1 Released

Posted on November 26, 2013May 8, 2020 by Alan

The Microsoft Enhanced Mitigation Experience Toolkit 4.1 has been released.  If you are using Windows OS you should be running EMET.  Even if you use the default setup, you will gain additional protection against malware.  Read the information in the link and install EMET.  Highly recommended.

Read more

Count Paired Items with PowerShell

Posted on November 26, 2013November 26, 2013 by Alan

This is just a code fragment for something that took me some time to figure out.  What I wanted to do is to count a pair of items.  The data was coming from a CSV file, and one of the two values is calculated. The code is: #Make arrays the lazy way, splitting string $UserList…

Read more

Use Out-Gridview to Select, Sort and Copy Output

Posted on November 9, 2013November 9, 2013 by Alan

PowerShell 3 introduced one of my favorite Cmdlet, Out-Gridview.  It allows you to pipe your output to a GUI where you can sort, and add criteria to limit what is displayed.  But you can’t use CTRL-C to copy the results.  Frustrated?  There is an easy answer: gwmi Win32_Process | Out-GridView -PassThru | clip By using…

Read more

Delete Inactive User Profiles with PowerShell

Posted on October 16, 2013February 25, 2017 by Alan

Written to replace DelProf, this script deletes inactive user profiles from a local or remote computer.  It supports arguments by position, and has a test parameter.  If you run it locally, you may supply host name, localhost or “.” The logfile is tab delimited, you may use XLS extension to open in Excel.  If you…

Read more

Get User’s Email Address from SmartCard with PowerShell

Posted on October 16, 2013June 8, 2025 by Alan

Someone asked me whether I could pull the email address of a user from an inserted SmartCard.  I knew I could dump the information in Windows 7 using the CertUtil command and wanted to experiment with parsing information with PowerShell.  The code can be very compact: $certInfo = certutil -scinfo -silent | Select-String -Pattern "RFC822"…

Read more

Get Last Domain Logon with PowerShell

Posted on October 16, 2013December 10, 2016 by Alan

You all know about lastlogontimestamp, and how AD replicates logon data in a lazy way.  As a result, when you want to know the last logon for a user you need to query all the domain controllers in your Active Directory Domain.  I found a script by Ahmed Malek on TechNet, but felt that his…

Read more

Open a Hyperlink URL from Clipboard

Posted on September 16, 2013 by Alan

I write scripts when I see a way to automate a task that I find myself doing repetitively.  Because I force email to text, I frequently get emails with URLs that have a line break.  Occasionally they will have a space, tab or even a greater than sign “>” if forwarded from another source.  I…

Read more

Enabling ISE and ActiveDirectory module on Windows 2008 R2 Member Server

Posted on August 23, 2013August 23, 2013 by Alan

So, I wrote a pretty cool script and sent it to a co-worker.  I wrote it on a Windows 7 PC with the RSAT tools installed.  My friend tried to run it on a 2008 R2 server with PowerShell 3.0, but the ActiveDirectory module would not load.  I tried to edit the script, but ISE…

Read more
  • Previous
  • 1
  • …
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • …
  • 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

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

Terms and Conditions - Privacy Policy