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/

Fix Creation Date Later than Date Modified with PowerShell

Posted on August 13, 2017 by Alan

A weird and annoying thing happened to my home directory at work when it was moved from Windows to a storage appliance. The file CreationTime was lost on all the files and was set to the date of the data move. Particularly annoying was seeing the CreationTime being more recent than the LastWriteTime attribute. At…

Read more

OU of Current PC from anywhere in the Forest

Posted on August 12, 2017September 23, 2017 by Alan

There are a lot of ways to get the OU of the current computer, but most don’t work if you are outside your home domain. This code does, without requiring AD cmdlets: #My Computername works anywhere in forest $strFilter = “(&(objectCategory=Computer)(Name=$env:computername))” $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.Filter = $strFilter $searchRootName = [system.directoryservices.activedirectory.forest]::GetCurrentForest().Name.ToString() $SearchRoot = “GC://”+$SearchRootName $objSearcher.SearchRoot…

Read more

An Empty Pipe Element is not Allowed Here – Workaround

Posted on August 12, 2017 by Alan

This code gives you the error, “An Empty Pipe Element is not Allowed Here”: $files = Get-ChildItem foreach ($file in $files) {$file.FullName } | Out-GridView -title “Example” The workaround which solves this problem is to make it an array by enclosing the code in @(), Example: $files = Get-ChildItem @(foreach ($file in $files) {$file.FullName })…

Read more

Split a List and Remove Empty Lines with PowerShell

Posted on August 12, 2017 by Alan

I often have lists where I have to split the list, and remove empty lines.  This is how I do it: $Properties =@” HostName TaskName Task To Run Start Date Start Time “@ $Properties.Split(“`r`n|`r|`n”,[System.StringSplitOptions]::RemoveEmptyEntries) This method uses a regular expression with three different variations of line break, then the .NET method of removing empty lines.

Read more

Create an AD Drive for Specified Domain

Posted on April 16, 2017 by Alan

When you load the Active Directory Module, you get, by default, an Active Directory PSDrive for the current domain.   You can avoid the drive from loading by setting $Env:ADPS_LoadDefaultDrive = 0. When writing scripts to export and import AD delegations, connecting to this remote drive became important to me. Here is an example of the…

Read more

Update to Dot Source Reminder with Search and Replace

Posted on April 2, 2017February 4, 2023 by Alan

“The pause doesn’t work for me”, said one of my team members about the pause function in my  Dot Source Reminder code.  We took some time to analyze why and found that his shell settings were different from mine.  Instead I decided to focus on whether the code executed inside the ISE.  Next was to…

Read more

Get MAC Address from IP Address

Posted on March 18, 2017August 12, 2017 by Alan

I got a call last week from a member of one the other teams where I work.  He asked, “Do you have a script which will resolve a list of IP Addresses to MAC Addresses?” My answer was, “not yet”.  I did a search and found some very convoluted Pinvoke code. I wanted something easier….

Read more

Open the PowerShell ISE (and other Programs) with Alternate Credentials

Posted on March 14, 2017 by Alan

RunAS for PowerShell is pretty easy. This opens the ISE: sl “c:\” $cred = Get-Credential $Prog = “c:\windows\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe” Start-Process $Prog -Credential $cred  

Read more

Update GPOs with Newer Version

Posted on March 1, 2017 by Alan

If you use GPOs to enforce baselines, you may find that your enterprise is moving from version 1.1 to version 1.2 of a GPO.  Unfortunately for you, version 1.1 linked in a dozen places.  Wouldn’t you rather just you search for version 1.1 and replace it with version 1.2?  Use Update-GPOLinks.ps1 to do just that. …

Read more

Get All GPOs Linked to an OU

Posted on March 1, 2017 by Alan

Get-AllGPOsLinkedToOU.ps1 returns a unique list of all GPO’s linked to an OU. You can also run a onelevel or subtree search to get a unique list of linked OUs at or below the selected OU. You are prompted for the domain, and navigate to desired OU.

Read more
  • Previous
  • 1
  • …
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • …
  • 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