Skip to main content

Posts

Showing posts from November, 2015

Keeping a Numeric Data Type a Number after Formatting

I’m up in Toronto, Canada tonight.  I’m delivering a custom 3 day PowerShell class.  Yes, 3 days.  Not a lot of time.  For that reason, no question is off the table.  Normally when a question is asked that is covered later in the course, I ask for them to hold off so we can build our knowledge base up a bit more so we can answer the question in more depth.  Did I mention that we only had 3 days!!!! So we had a question after I used Get-Volume.  It turns out that we have some PowerShell V4 users on Windows 7 in the audience.  Get-Volume is from the Storage module that comes from the Windows 8 operating system, they could not use it.  Since we were about to cover calculated properties, I went ahead and used that as an opportunity to take a question and make a lesson out of it.  Here is our code. 1 2 3 4 GWMI Win32_Volume | Select -Property DriveLetter ,     @{N = "SizeGB" ;E = { $_ . Capacity / 1gb }} , ...