header image

Archive for July, 2015

get-computerDN function

Posted by: | July 16, 2015 Comments Off on get-computerDN function |

Last time I showed a bare bones function for using [adsisearcher] to retrieve the distinguished name of a domain computer. This is a somewhat expanded version of that function which adds in the sorts of features you’d want for a production ready function. function get-computerDN { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="Low")] param ( [parameter(Position=0,    Mandatory=$true,    ValueFromPipeline=$true, […]

under: PowerShell and Active Directory

ADSIsearcher returns

Posted by: | July 15, 2015 Comments Off on ADSIsearcher returns |

I’ve been using the Microsoft AD cmdlets (and before that the Quest cmdlets) for so long that I’d sort of forgotten about [adsisearcher]. It was introduced in PowerShell 2.0 and is a shortcut for System.DirectoryServices.DirectorySearcher   A question in the forum about using this remotely made me realise that many people have probably never used […]

under: PowerShell and Active Directory

Disk identification

Posted by: | July 14, 2015 Comments Off on Disk identification |

A recent question on the forums regarded using the Win32_LogicalDisk class to retrieve disk size and free space data.  A filter based on the disk letter was being used. The main error with the code was that the filter was being expressed as   "DeviceId=’E’" rather than "DeviceId=’E:"   The colon is necessary as its […]

under: PowerShell and WMI, PowerShell Basics

PowerShell and messaging

Posted by: | July 11, 2015 Comments Off on PowerShell and messaging |

This article – http://powershell.org/wp/2015/07/07/rabbitmq-and-powershell/ – reminded me that Windows server comes with a built-in messaging system – MSMQ.   There is a PowerShell module for MSMQ – https://technet.microsoft.com/en-us/library/hh405007(v=vs.85).aspx   Since reading the RabbitMQ article I think that Rabbit is more useful in a heterogeneous environment but MSMQ would work very nicely in a Windows only […]

under: PowerShell, Windows Server 2012 R2

POwerShell Gallery taking registrations

Posted by: | July 8, 2015 Comments Off on POwerShell Gallery taking registrations |

The PowerShell team have just announced that the PowerShell gallery is now open for YOU to post your module. You need to register to be able to post code to the gallery.   http://blogs.msdn.com/b/powershell/archive/2015/07/07/powershell-gallery-registration-is-now-unrestricted.aspx   This is a significant step forward in making PowerShell code available to others – if you have a cool module […]

under: WMFv5

DSC validation

Posted by: | July 7, 2015 Comments Off on DSC validation |

The PowerShell team are asking for validation and feedback on the DSC features in WMF 5.0 – http://blogs.msdn.com/b/powershell/archive/2015/07/06/validate-features-of-powershell-dsc.aspx   First up is the PowerShell DSC RunAsCredential – http://blogs.msdn.com/b/powershell/archive/2015/07/06/validate-powershell-dsc-runascredential.aspx   Other features will be explained and your validation solicited over the course of this week

under: DSC, WMFv5

Number of working days

Posted by: | July 7, 2015 Comments Off on Number of working days |

Need to know the number of working days left until a specific date?   $we = [System.DayOfWeek]::Saturday, [System.DayOfWeek]::Sunday $date = Get-Date -Year 2015 -Month 8 -Day 28 $now = (Get-Date).AddDays(-1) $workdays = 0 while ($now -le $date){   $now = $now.AddDays(1) if ($now.DayOfWeek -notin $we ) {   $workdays++ } } $workdays   Create a […]

under: PowerShell Basics

Scripting Guy new series

Posted by: | July 5, 2015 Comments Off on Scripting Guy new series |

Ed Wilson, the Scripting Guy, is starting a new series of posts on writing PowerShell scripts – he’ll also cover what to script, when to script and when to work interactively.   First post is here http://blogs.technet.com/b/heyscriptingguy/archive/2015/07/05/weekend-scripter-when-to-write-a-powershell-script.aspx   Strongly recommend this series to all PowerShell users

under: PowerShell

Scripting Games July 2015 puzzle

Posted by: | July 4, 2015 Comments Off on Scripting Games July 2015 puzzle |

Head over to http://powershell.org/wp/2015/07/04/2015-july-scripting-games-puzzle/ for our inaugural Scripting Games puzzle.   I’ll publish a solution at the end of the month

under: PowerShell, PowerShell.org, Scripting Games

Processing NULL AD values

Posted by: | July 2, 2015 Comments Off on Processing NULL AD values |

Back in this post https://richardspowershellblog.wordpress.com/2012/12/09/bulk-modifications-using-set-aduser/ I showed how to perform a bulk change to a number of AD accounts using a CSV file to input the data I was recently asked what happens if one of the input values is null. £> Set-ADUser -Identity fgreen  -Division ‘Test’ £> Get-ADUser -Identity fgreen  -Properties Division DistinguishedName : […]

under: PowerShell and Active Directory

« Newer Posts - Older Posts »