Skip to main content

Posts

Quick Help in SAPIEN PowerShell Studio

While my students in my Windows Server 2012 Class were working on a lab, I’ve been working on a little idea (Yes, I will blog about the idea later).  Anyway, I’m working on a new GUI in SAPIEN PowerShell Studio and I’m looking at the Windows Form Objects.  I needed to read some MSDN data on an object and realized something.  I’ve never right clicked on any of the Windows Form Controls.  Take a look at this. It may not seem like a big deal, but I just got a little more productive. The other nice thing about this is the View Spotlight Article .  If SAPIEN blogged some extra knowledge about how to use a particular control, you have a quick link to it.  Both of these are real nice features.  With the growth in both interest and usage of PowerShell showing no signs of slowing down, I’m not the only PowerShell enthusiast looking to extend my investment in learning PowerShell beyond just scripts.  These two features are going to help a lot. Enough blo...

Why does my CSV file contain Microsoft.ActiveDirectory.management.ADPropertyValueCollection

The answer to this has to do with how a CSV file is used with PowerShell. In a CSV file, you are importing objects to be used with PowerShell.  The first line list all of the property names of the objects.  Each line after that is a unique object with the value of the property.  Take a look below: Name GivenName SurName City Office Jason Yoder Jason Yoder Indianapolis HQ Matt Myers Matt Myers Tampa Regional   In this example, we are creating 2 objects.  Each object will have 5 properties: Name GivenName SurName City Office CSV property values can only hold a singular value.  Many properties that you come across will contain multiple properties.  Take a look at this example: PS C:\> Get-ADUser -Identity Administrator -Properties MemberOf     DistinguishedName : CN=Administrator,CN=Users,DC=PowerIT,DC=com Enabled            : True GivenName    ...

Read The Help Files

One of the things that I urge, if not plead, in my PowerShell classes is to read the help files.  I’ve been working with PowerShell since it was called Monad.  I honestly cannot work with PowerShell unless I use the help system.  One of the reasons why I want IT Pros to read the help files is so they do not “assume” something.  Take this code that I looked at on PowerShell.Com’s forums.     get-content -path c:\temp\servers.txt |   foreach { Get-WmiObject win32_service } |   select pscomputername , displayname , startname   The problem that the IT Pro was having is that the PSComputerName property was always his local client, not the remote computer.  The help file for Get-WMIObject says this about the ComputerName parameter: -ComputerName [<String[]>]     Specifies the target computer for the management operation. Enter a fully     qualified domain name, a NetBIOS name, or an IP ad...

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 }} , ...