DCSIMG
gotcha - Shay Levy

Shay Levy

If you repeat it, PowerShell it!

Browse by Tags

All Tags » gotcha (RSS)
Invoking WMI methods in PowerShell
In PowerShell V1 if we wanted to invoke a method, the Win32_Volume WMI Format method in the following example, we used a syntax like: PS > $vol = Get-WmiObject -Class Win32_Volume -Filter "DriveLetter='R:'" PS > $vol.Format(...) Note : The Win32_Volume class exists on Windows Server 2003 and above, on Windows XP this class is not available. To determine the values we need to pass to the Format method we pipe the volume object to the Get-Member cmdlet and look at the method...
Using variables in EMS Filter parameter
The Filter parameter is one of my favorite parameters in EMS (Exchange Management Shell). It is one of the most robust parameters in EMS as it enables us to filter objects on the server (using a PowerShell expression) instead of using the Where-Object cmdlet, which filters objects on the client. In Exchange 2007, we could use a simple filter expression to get all mailbox objects which have the Office attribute set to 'Sales': [PS] > Get-Mailbox -Filter {Office -eq 'Sales'} | Format...
PSClientManager – PowerShell module to Add/Remove Windows 7 features
Windows Server 2008 R2 includes a PowerShell module, ServerManager , for managing server roles, role services, and features via PowerShell cmdlets. In Windows 7, there is no such module and we need to use the GUI (OptionalFeatures.exe) or the ‘Deployment Image Servicing and Management’ tool (DISM, see list of resources below). The problem with DISM, from a PowerShell perspective (objects, objects…), is that DISM is a legacy application that emits text and is not written with automation in mind ....
PowerShell ISE on Windows Server 2008 R2
As you probably know PowerShell 2.0 is installed by default on Windows 7 and Windows Server 2008 R2 .  PowerShell 2.0 shipped with a new feature called Windows PowerShell Integrated Scripting Environment (ISE) , A graphical user interface code editor. In PowerShell 2.0 you can launch ISE simply by executing ‘ise’ in the console (built-in Alias) or by clicking on its shortcut(s) in the programs menu. However, on Windows Server 2008 you won’t be able to find it:   If you open PowerShell and...
Module manifest gotcha
Module authors can use a manifest file for their modules (although this is not required). A manifest file is a .psd1 file that contains a hash table. The keys and values in the hash table describe the contents and attributes of the module, define the prerequisites, and determine how the components are processed. How do you know all the hash table keys? You don’t have to. PowerShell can create the file for you with the New-ModuleManifest cmdlet. New-ModuleManifest creates a new module manifest (.psd1...