Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options questions only not deleted user 40484

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and CIM enabling management of remote Linux systems and network devices.

3 votes
1 answer
805 views

PowerShell Unpivot Object

Based on a question on SO I thought I'd knock up a cmdlet to perform an unpivot on an object. I've not yet considered all the options (e.g. what happens when objects with empty lists are passed), so …
JohnLBevan's user avatar
  • 1,409
4 votes
1 answer
85 views

Enforcing Paired Statements Using ScriptBlock

I realised that something similar can be achieved in PowerShell; e.g. …
JohnLBevan's user avatar
  • 1,409
5 votes
2 answers
421 views

Powershell Export function to create environment variables with bash syntax

Most of those same commands work seamlessly in PowerShell; but setting environment variables doesn't; e.g. export DEMO_CLIENT_ID="ff3b7b84-e041-4e76-993e-239930808aa7". …
JohnLBevan's user avatar
  • 1,409
3 votes
0 answers
2k views

PowerShell Supports Paging

I've not played with SupportsPaging before, so wanted to knock up some demo code & get feedback on whether my implementation is OK, or if I've misunderstood something. I created the function 'Invoke- …
JohnLBevan's user avatar
  • 1,409
2 votes
0 answers
111 views

Sort items so that parents are created before their children

I've been asked to create some code to help automate the loading of data into a system based on employee data in a spreadsheet. However, the data isn't clean, so some people may have no manager, some …
JohnLBevan's user avatar
  • 1,409
4 votes
1 answer
4k views

Get AD Users' Latest Last Logon Dates across Multiple DCs

I was recently asked to help our Spanish BU to audit their AD for inactive accounts. Grabbing a script from online I gave them this: https://gallery.technet.microsoft.com/scriptcenter/Get-Active-Dire …
JohnLBevan's user avatar
  • 1,409
3 votes
0 answers
837 views

Easily Create XML within PowerShell

The purpose of this PowerShell function is to make it simpler to output XML in a given format. …
JohnLBevan's user avatar
  • 1,409
1 vote
1 answer
2k views

Write to the event log without needing to check whether or not it exists by use of a `-Force...

Below is some powershell to write to the event log; if the -Force parameter is specified this saves you the effort of writing additional code to first check whether the log exists. …
JohnLBevan's user avatar
  • 1,409
25 votes
1 answer
4k views

Powershell to quickly ping a number of machines

I came up with the below code to improve the peformance of pinging a large number of machines. At present it's fairly basic, but thought I should see what people thought before proceeding further. NB …
JohnLBevan's user avatar
  • 1,409
5 votes
1 answer
448 views

Powershell to break apart large flat files (e.g. csv)

Filename)) { throw "File '$Filename' does not exist" } $file = Get-Item $Filename [string]$OutputFilenameFormat = join-path -path ($file.PSParentPath -replace 'Microsoft\.PowerShell
JohnLBevan's user avatar
  • 1,409
2 votes
1 answer
12k views

Powershell to Convert HTML Table to Array of PSCustomObject

I created the below script to sent a request to a website, then convert the table in the results to an array of PSObjects which I can work with in PowerShell. …
JohnLBevan's user avatar
  • 1,409
3 votes
0 answers
460 views

Escape Characters for LDAP/ADSI string

Below's some code I knocked up to escape the account name to be used in creating an ADSI reference to an account (e.g. escaping $sAmAccountName before using in [ADSI]"WinNT://$Domain/$sAmAccountName,u …
JohnLBevan's user avatar
  • 1,409
2 votes
1 answer
3k views

Escaping characters in a WMI Query

I've knocked up this code to allow me to query for specific service names using PowerShell. I'm after the executable (PathName) for the service, so the Get-Service cmdlet is not appropriate here. …
JohnLBevan's user avatar
  • 1,409
2 votes
0 answers
271 views

Syncing NTFS permissions with SMB share permissions

I recently wrote scripts to automate the setup of shares on a server using the New-SmbShare cmdlet. I hadn't realised that this cmdlet doesn't automatically amend the underlying NTFS permissions to h …
JohnLBevan's user avatar
  • 1,409
4 votes
1 answer
1k views

Work with configuration files holding encrypted credentials

The idea with this script is to provide a way to work with configuration (xml) files for PowerShell scripts. … This script is written for PowerShell v5. My scenario didn't require support for older versions, so this implementation's not taken those into account. …
JohnLBevan's user avatar
  • 1,409

15 30 50 per page