Monthly Archives: January 2015

Modifying text

I needed to modify some text somewhere in a file. The file looks like this ##  start fileThis is some text. I want to change something. But not this.##  end file I was playing around with various options.  The simplest … Continue reading

Posted in Powershell Basics | 1 Comment

Testing for a hotfix

KB3000850 – the November roll up for Windows 2012 R2 contains some very useful updates. I’ve installed it on some machines in my lab but not all. The update is huge so I’m installing it manually rather than through WSUS. … Continue reading

Posted in CIM, PowerShell and CIM, PowerShell and WMI | Leave a comment

Variable select

I was working on some code that  accesses a SQL database this afternoon. I only needed to pull back a single column from a single row but which column to pull back is variable depending on other data. That’s OK … Continue reading

Posted in Powershell Basics | Leave a comment

WMI errors

Most PowerShell users will have done something like this: £> Get-WmiObject -ClassName Win32_ComputerSystemDomain              : WORKGROUPManufacturer        : Microsoft CorporationModel               : Surface Pro 2Name                : RSSURFACEPRO2PrimaryOwnerName    : TotalPhysicalMemory : 8506093568 Or you can use a computername to access a remote system £> … Continue reading

Posted in PowerShell and WMI | Leave a comment

Unravelling lists of distinguished names

There are a number of AD properties such as MemberOf and directrports that consist of a collection of distinguisednames.  Sometimes you need the  name  of the object rather than the distinguished name: function getname {[CmdletBinding()]param ( [string]$dn) $name = Get-ADObject … Continue reading

Posted in PowerShell and Active Directory | Leave a comment

Filtering on if an AD property exists

There are times when you want to filter the results based on whether a user has an AD property set.  You could do this: Get-ADUser -Filter * -Properties Title | Where Title  | select Name, Title However, that involves pulling … Continue reading

Posted in PowerShell and Active Directory | Leave a comment

Awkward file and folder names

Spent some time today dealing with a situation where there were special characters – namely [ ] in folder a file names £> Get-ChildItem -Path C:\Test     Directory: C:\Test Mode                LastWriteTime     Length Name—-                ————-     —— —-d—-        21/01/2015     17:58            Awkward [One]d—-        … Continue reading

Posted in File system, Powershell Basics | Leave a comment