Posts tagged with "powershell"

Checking SSL and TLS Versions With PowerShell

With all the SSL vulnerabilities that have come out recently, we've decided to disable some of the older protocols at work so we don't have to worry about them. After getting our group policies setup the way we wanted, we needed a way to validate that the protocols we wanted to disable were actually disabled on our servers.


Creating QR Codes in PowerShell

I wrote a module as a wrapper around the .Net port of Google's ZXing library to allow me to create QR codes in PowerShell. It hasn't been used a ton, but I figured it was finally time for me to share it with the rest of the world so I published it out on my GitHub.


Hacking ValidateSet

I guess I should start off this post by saying what I'm doing is a dirty hack, in no way supported, and in general a terrible idea. But it's also really awesome.


SharePoint 2007 Wiki Pages Broken

One of our SharePoint wiki libraries got in a state where we couldn't edit any of the pages. When we clicked "Edit" we would get the document properties page instead of the wiki editor page. I believe the root cause was someone moving a page from another wiki and the page ended up in the library as a "document" instead of a "wiki page".


Deploying WDS Across Domain Forests

I'm not going to cover how to setup your unattend file, or how to customize a PE imageā€¦ there are plenty of people out there who have covered those topics. What I do want to cover here is how to edit your PE image so that you can force it to connect to a specific WDS server. This will help solve the problem where you want to deploy computers into two domains on the same subnet, but WDS only looks for prestaged computers objects on the domain it is joined to.


Re: Zero Out Free Disk Space

We've been having weekly script club meetings at work where anyone who is interested gets together in a conference room and we all work on scripts together so we all have a chance to learn new techniques while solving our real-world problems at the same time. This week I developed a script to mimic the behavior of the SysInternals utility SDelete. The script will be used to reclaim thin-provisioned space from our SAN, and I wanted to develop it during script club to use as an example of how to use the classes in the System.IO namespace to get better IO performance from PowerShell.


A PowerShell Alternative to SDelete
Many storage appliances support thin provisioning by not storing large blocks of zeros on disk, thus saving expensive physical disks for actual data. One of the challenges of this feature is that Windows (or most file systems really) does not zero out space that was used by files that have been deleted. This means that over time as files are written an deleted, the amount of physical disk that is saved by thin provisioning grows smaller.

Powershell ValidateNotNullOrEmpty Bug

I was showing a co-worker how easy it is to ensure that the parameters to his script were actually being set using the [Parameter(Mandatory=$true)] and [ValidateNotNullOrEmpty()] decorators on his parameter declaration block, and we encountered a bug where he was able to pass an empty string as a parameter to his function and the validation did not catch it.


Casting Objects to Boolean in Powershell

A question came up on the Powershell technet forum asking why an empty System.DirectoryServices.SearchResultCollection was evaluating to $true. The original post is HERE, but the gist of the question is this:


April MS Patch Issue

After deploying our April patches we were having trouble with our Exchange servers, specifically our web mail servers were not responsive and we had high cpu utilization on all our Exchange (2010) boxes (sorry, I don't know exactly which process was going crazy with the CPU). In our initial troubleshooting, it was discovered that other symptoms were Event Viewer and Powershell both crashed immediately upon loading. This pointed us to KB2540222.


Convert a Windows SID from Binary to SDDL Form

At work I had a problem that required me to decode a SID that was stored in a database in binary form in order to locate the user/group that it represented. It turns out this is fairly easy to do, but I couldn't find a Powershell solution online and the solutions in those "other" languages tended to be overly complicated.


Issues With Configuring Powershell ExecutionPolicy via Group Policy

When you publish an ExecutionPolicy for Powershell via Group Policy, several issues will crop up. The first I came across is that it breaks several of the Best Practices Analyzers. The second is that it breaks some of the Exchange 2010 installers.


Querying Peak Commit Bytes with Powershell (via NtQuerySystemInformation)

One of the more interesting values to determine how much memory to allocate a machine is the Peak Committed Bytes. This value is available as "Commit Charge (K) - Peak" from Windows 2003 Task Manger and from Sysinternals Process Explorer and is a good representation of the maximum amount of memory that has been used at once since the computer was last rebooted. Wikipedia has more details about the Commit Charge numbers if you want to read more.



(Not) Using PowerShell v2 to View WSMan Data From ESX

Today I was trying to get at my "Health Status" data on my ESX servers though PowerShell using the tutorial posted on the PowerCLI Blog (Monitoring ESX Hardware with Powershell), but I kept getting an "Access Denied" message. I did a little more research into using WSMan in PowerShell and discovered that before V2, there was a way to use a COM object to query WSMan that gave you a little more control over the connection (http://technet.microsoft.com/en-us/magazine/2007.11.heyscriptingguy.aspx).