<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>4sysops &#187; powershell</title>
	<atom:link href="http://4sysops.com/archives/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://4sysops.com</link>
	<description>For Windows Administrators</description>
	<lastBuildDate>Thu, 24 May 2012 23:49:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<image>
    <title>4sysops</title>
    <url>http://4sysops.com/4sysops-rss.png</url>
    <link>http://4sysops.com</link>
    <width>143</width>
    <height>49</height>
    <description>4sysops.com</description>
    </image>		<item>
		<title>Query free disk space details of remote computers using PowerShell</title>
		<link>http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/</link>
		<comments>http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 19:30:40 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[remote management]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=8138</guid>
		<description><![CDATA[The PowerShell script introduced in this post is for getting disk space details of multiple remote computers. It also retrieves the space details of mount points.]]></description>
			<content:encoded><![CDATA[<p><strong><i>The PowerShell script introduced in this post is for getting disk space details of multiple remote computers. It also retrieves the space details of mount points.</i></strong></p>
<p>Disk space monitoring is an important system administration task because disk space shortage can impact system stability and application functionality.</p>
<p>I wrote a PowerShell script that allows you to query the disk space details of any drive connected to a remote Windows computer. Moreover, the script can get the disk space details of multiple computers in a single shot. You can also use it with other cmdlets, such as Get-QADComputer and Get-ADComputer, and pass the output of these commands to the script.</p>
<p>Using the parameters <strong>ValueFromPipelineByPropertyName</strong> and <strong>ValueFromPipeline</strong>, the script reads the inputs from the pipeline (output of the previous command). You can learn more details about these parameters by executing the command below in a PowerShell console.</p>
<pre>Get-help about_functions_advanced_parameters</pre>
<p>The <strong>-ComputerName</strong> parameter accepts a single computer name or a list of computers. The script then verifies the reachability of each computer before executing a WMI query. If the computer is not reachable, it proceeds to the next computer account.</p>
<p>I used the <strong>Win32_Volume </strong>WMI class to fetch the disk space details. A computer can have different drive types, such as local disks, removable disks, CD drives, or network drives. I am only interested in knowing the disk space details of local disks and removable disks, so I am tuning the command to return only the drive types 2 and 3. The PowerShell code below shows the WMI query and filtering I used in the script.</p>
<pre>Get-WmiObject -ComputerName $Computer -Class Win32_Volume | ? {$_.DriveType -eq 2 
  -or $_.DriveType -eq 3 }</pre>
<p>Once I get the list of drives, I go through each volume and read the total capacity and free space attributes. These attributes provide the disk information in bytes. I then divide the value by 1GB (PowerShell supports this) to convert the bytes to GBs. The <strong>Round </strong>method in the <strong>System.Math</strong> class adjusts the value to two decimals. Based on these two values, I then calculate the total percentage free space.</p>
<pre>$Capacity = [System.Math]::Round(($Volume.Capacity/1GB),2)

$FreeSpace = [System.Math]::Round(($Volume.FreeSpace/1GB),2)

$PctFreeSpace = [System.Math]::Round(($Volume.FreeSpace/$Volume.Capacity)
 *100,2)</pre>
<p>The next step is to format the output in a way that it can be passed to other scripts as input and can be used in filters to get the data we need. For this purpose, I am using <strong>PSObject</strong> to output the values.</p>
<pre>$OutputObj = New-Object -TypeName PSobject

$OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName 
 -Value $Computer

$OutputObj | Add-Member -MemberType NoteProperty -Name DriveName 
 -Value $Volume.Caption

$OutputObj | Add-Member -MemberType NoteProperty -Name DriveType 
 -Value $Volume.DriveType

$OutputObj | Add-Member -MemberType NoteProperty -Name "Capacity `(GB`)" 
 -Value $Capacity

$OutputObj | Add-Member -MemberType NoteProperty -Name "FreeSpace `(GB`)" 
 -Value $FreeSpace

$OutputObj | Add-Member -MemberType NoteProperty -Name "`%FreeSpace `(GB`)" 
 -Value $PctFreeSpace

$OutputObj# | Select ComputerName, DriveName, DriveType, Capacity, FreeSpace, 
 PctFreespace | ft -auto</pre>
<p><strong>A few tips for using the script:</strong></p>
<ul>
<li>Use “Get-Help .\Get-DiskSpaceDetails.ps1” if you want to display usage information.</li>
<li>Use “Get-Content c:\comps.txt | .\Get-DiskSpaceDetails.ps1” to get the disk space details of computers listed in comps.txt.</li>
<li>Use the “-Verbose” switch if the output is not displayed for a computer.</li>
<li>Use “Get-DiskSpaceDetails.ps1 -ComputerName Comp1, Comp2, Comp3” if you want to pass the computer names as parameters.</li>
<li>Execute the script without any parameters (.\Get-DiskSpaceDetails.ps1) to return the disk space details of the local computer.</li>
<li>Use “Get-DiskspaceDetails.ps1 -ComputerName Comp1 | ? {$_.”`%FreeSpace `(GB`)” -lt 5}” if you want to get a list of drives that have less than 5% free space.</li>
</ul>
<p>You can download the script <a href="http://4sysops.com/wp-content/uploads/2012/03/Get-DiskSpaceDetails.ps1">here</a>. Feel free to adjust it to your liking.</p>
Author: Sitaram Pamarthi
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/raffle-solarwinds-dameware-nt-utilities-remote-administration-tools/" title="Raffle: SolarWinds DameWare NT Utilities &#8211; Remote administration tools (April 18, 2012)">Raffle: SolarWinds DameWare NT Utilities &#8211; Remote administration tools</a> (3)</li>
	<li><a href="http://4sysops.com/archives/windows-to-mac-remote-management-with-vnc-and-ssh/" title="Windows-to-Mac remote management with VNC and SSH (March 22, 2012)">Windows-to-Mac remote management with VNC and SSH</a> (1)</li>
	<li><a href="http://4sysops.com/archives/free-paexec-run-programs-on-remote-windows-servers/" title="FREE: PAExec &#8211; Run programs on remote Windows servers (March 12, 2012)">FREE: PAExec &#8211; Run programs on remote Windows servers</a> (0)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Change the local administrator password on multiple computers with PowerShell</title>
		<link>http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/</link>
		<comments>http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 19:50:09 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=7810</guid>
		<description><![CDATA[The PowerShell script discussed here allows you to change the local administrator password on multiple remote computers. You can also use the script to change the password of other accounts.]]></description>
			<content:encoded><![CDATA[<p><strong><i>The PowerShell script discussed here allows you to change the local administrator password on multiple remote computers. You can also use the script to change the password of other accounts.</i></strong></p>
<p>I still remember the days (way back in 2003-2004) when we were asked to change the local administrator password manually on all 2000+ computers in a weekend. Back then, system administrators in my region were pretty far removed from automation. But things evolved greatly after that, and system administrators started using programming languages (like VBScript) to automate tasks. Automation tasks have become much easier these days with the introduction of PowerShell.</p>
<p>So, let us see how we can change the local administrator password for a given list of computers using a PowerShell script.</p>
<h2>Changing the administrator password with PowerShell</h2>
<p><code>$password = Read-Host &quot;Enter the password&quot; -AsSecureString     <br />$confirmpassword = Read-Host &quot;Confirm the password&quot; -AsSecureString      <br />$pwd1_text = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))      <br />$pwd2_text = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($confirmpassword))      <br />if($pwd1_text -ne $pwd2_text) {      <br />&#160;&#160;&#160; Write-Error &quot;Entered passwords are not same. Script is exiting&quot;      <br />&#160;&#160;&#160; exit      <br />}</code></p>
<p>As you will notice in the above code, I am prompting to confirm the password twice so that it won’t be entered wrong and cause the script to run again. I am also reading the password in a secure manner so that no one else can see it when it is being typed. Once the password is confirmed, the next two lines of dotnet code convert the password into plain text for comparison. If the comparison fails, the script exits; otherwise, it continues.</p>
<p>Now that we have the password, it is time to read the list of computers from a text file.</p>
<h2>Reading list of computers</h2>
<p><code>if(!(Test-Path $InputFile)) {   <br />&#160;&#160;&#160; Write-Error &quot;File ($InputFile) not found. Script is exiting&quot;    <br />&#160;&#160;&#160; exit    <br />}</code></p>
<p>$Computers = Get-Content -Path $InputFile</p>
<p>Before reading the text file, I am doing a small check to see if that file exists or not. If the file is not found, the script exits. Otherwise, the script reads the contents of the file using the <strong>Get-Content</strong> cmdlet and stores the list in an array called $computers.</p>
<p>Now that we have the list of computers, we can start changing the password for each computer. That is what the below code does.</p>
<h2>Chaging the password on multiple computers</h2>
<p><code>foreach ($Computer in $Computers) {   <br />&#160;&#160;&#160; $Computer&#160;&#160;&#160; =&#160;&#160;&#160; $Computer.toupper()    <br />&#160;&#160;&#160; $Isonline&#160;&#160;&#160; =&#160;&#160;&#160; &quot;OFFLINE&quot;    <br />&#160;&#160;&#160; $Status&#160;&#160;&#160;&#160;&#160;&#160;&#160; =&#160;&#160;&#160; &quot;SUCCESS&quot;    <br />&#160;&#160;&#160; Write-Verbose &quot;Working on $Computer&quot;    <br />&#160;&#160;&#160; if((Test-Connection -ComputerName $Computer -count 1 -ErrorAction 0)) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Isonline = &quot;ONLINE&quot;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;`t$Computer is Online&quot;    <br />&#160;&#160;&#160; } else { Write-Verbose &quot;`t$Computer is OFFLINE&quot; }</p>
<p>&#160;&#160;&#160; try {   <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $account = [ADSI](&quot;WinNT://$Computer/Administrator,user&quot;)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $account.psbase.invoke(&quot;setpassword&quot;,$pwd1_text)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;`tPassword Change completed successfully&quot;    <br />&#160;&#160;&#160; }    <br />&#160;&#160;&#160; catch {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $status = &quot;FAILED&quot;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;`tFailed to Change the administrator password. Error: $_&quot;    <br />&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; $obj = New-Object -TypeName PSObject -Property @{   <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ComputerName = $Computer    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; IsOnline = $Isonline    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PasswordChangeStatus = $Status    <br />&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; $obj | Select ComputerName, IsOnline, PasswordChangeStatus   <br />&#160;&#160;&#160; <br />&#160;&#160;&#160; if($Status -eq &quot;FAILED&quot; -or $Isonline -eq &quot;OFFLINE&quot;) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $stream.writeline(&quot;$Computer `t $isonline `t $status&quot;)    <br />&#160;&#160;&#160; }    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />}</code></p>
<p>I am looping through each computer account in the array and first checking if it is online or not by using the <strong>Test-Connection</strong> cmdlet. This cmdlet does a ping check by sending one ICMP packet to the computer. If the ping is successful, the script changes the password. To do that, I am using the WinNT interface, which is pretty famous from VBScript days. After I get the reference to the administrator account, I invoke a method called <strong>SetPassword</strong> to change the password. If the password change fails, the respective error will be recorded using the <strong>catch</strong> block.</p>
<p>That’s it. The script has done its job and you will see the result in the console.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2012/01/Change-administrator-password-PowerShell.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2012/01/Change-administrator-password-PowerShell.png','',event,300,75)"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Change administrator password PowerShell" border="0" alt="Change administrator password PowerShell" src="http://4sysops.com/wp-content/uploads/2012/01/Change-administrator-password-PowerShell_thumb.png" width="604" height="146" /></a></p>
<p>As you’ll notice in the output, the script creates a list of computers where the password has failed. The file &quot;failed-computers.txt&quot; is stored in the directory where the script picked up the computers list. If you want to provide a different directory where you want to store files, just pass the directory name to the <strong>-OutputDirectory</strong> parameter while executing the script.</p>
<p><strong>Download the complete script from <a href="http://4sysops.com/wp-content/uploads/2012/01/Change-admin-password-on-multiple-computers-with-PowerShell.ps1">here</a>.</strong></p>
<h2><strong>A few tips for using this script</strong></h2>
<p>Type “Get-Help .\Update-LocalAdministratorPassword.ps1 -Detailed” in a PowerShell console for help.</p>
<ul>   
<li>Use the -Verbose switch from the command line if you want to see the debug information and error messages at each stage. </li>
<li>Passing the file name to the script is optional. The script will prompt you for the file if you don’t pass it. </li>
<li>Using this script, you can change the password of any local account. Just replace “administrator” with the account name for which you want to change the password. </li>
</ul>
Author: Sitaram Pamarthi
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-5-using-powershell-scriptomatic/" title="PowerShell tutorial for admins &#8211; Part 5: Using PowerShell Scriptomatic (July 7, 2011)">PowerShell tutorial for admins &#8211; Part 5: Using PowerShell Scriptomatic</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Query and kill a process on a remote computer using PowerShell and WMI</title>
		<link>http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/</link>
		<comments>http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 19:00:36 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=7593</guid>
		<description><![CDATA[This tutorial discusses a few PowerShell scripts that allow you to query and kill a process on a remote computer using WMI (Windows Management Instrumentation).]]></description>
			<content:encoded><![CDATA[<p><strong><i>This tutorial discusses a few PowerShell scripts that allow you to query and kill a process on a remote computer using WMI (Windows Management Instrumentation).</i></strong></p>
<p>Querying processes running on local and remote computers is one of the most common jobs of system administrators. We sometimes need to know which user is running some XYZ application. If you know the process name of the application, then you can quickly scan all your network computers to see how many hosts are running that particular process, and for how long, so that you can prepare an application usage report.</p>
<h2>Query process information</h2>
<p>Let&#8217;s first see how we can check if a process is running or not. For example, the following command checks if Notepad is running and, if so, displays information about the process:</p>
<p><code>Get-Process -Name notepad.exe</code></p>
<p>You will get information about the process, if it is running. You can use the -ComputerName parameter with the command to check if the process is running on a given remote computer. For example:</p>
<p><code>Get-Process -ComputerName PC1 -Name notepad.exe</code></p>
<p>You can get similar information with other scripting languages like VBScript and Perl. So what is so special about PowerShell? The answer is that it helps you to get granular information about processes you are querying, such as process creation time, the owner of a given process (with which account it is started), command line information about the process, the title of the application, and much more.</p>
<p>Below are a few example code snippets.</p>
<h2>Process creation time</h2>
<p><i>Get-ProcessCreationTime.ps1</i>
<code>
[cmdletbinding()]<br />
param(<br />
$ComputerName=$env:COMPUTERNAME,<br />
[parameter(Mandatory=$true)]<br />
$ProcessName<br />
)<br />
$Processes = Get-WmiObject -Class Win32_Process -ComputerName $ComputerName -Filter "name='$ProcessName'"<br />
if($Processes) {<br />
foreach ($process in $processes) {<br />
$processid = $process.handle<br />
$processcreationtime = $Process.Converttodatetime($Process.creationdate)<br />
write-host "`nThe $ProcessName `($processid`) process creation time is $processcreationtime"<br />
}<br />
} else {<br />
write-host "`nNo Process found with name $ProcessName"<br />
}<br />
write-host ""
</code></p>
<p>The above script takes computer name and process name as arguments. The computer name is optional and defaults to the local computer if not provided. The process name is mandatory, and the script will throw an error if you don’t provide it. After reading the arguments, a WMI query gets the list of processes using the names in the argument and iterates through each process to get its creation date.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/12/Process-creation-time.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/12/Process-creation-time.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Process creation time" src="http://4sysops.com/wp-content/uploads/2011/12/Process-creation-time_thumb.png" alt="Process creation time" width="604" height="183" border="0" /></a></p>
<p align="center"><em>Process creation time</em></p>
<h2>Process owner</h2>
<p><em>Get-ProcessOwner.ps1</em>
<code>
[cmdletbinding()]<br />
param(<br />
$ComputerName=$env:COMPUTERNAME,<br />
[parameter(Mandatory=$true)]<br />
$ProcessName<br />
)<br />
$Processes = Get-WmiObject -Class Win32_Process -ComputerName $ComputerName -Filter "name='$ProcessName'"<br />
if($Processes) {<br />
foreach ($process in $processes) {<br />
$UserName = $process.getowner().user<br />
$DomainName = $process.getowner().domain<br />
$processid = $process.handle<br />
write-host "`nThe owner of $ProcessName `($processid`) process is $domainname`\$username"<br />
}<br />
} else {<br />
write-host "`nNo Process found with the name"<br />
}<br />
write-host ""</code>
This script executes in the same way as the Process creation time script.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/12/Process-owner.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/12/Process-owner.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none;" title="Process owner" src="http://4sysops.com/wp-content/uploads/2011/12/Process-owner_thumb.png" alt="Process owner" width="600" height="138" /></a></p>
<p align="center"><em>Process owner</em></p>
<h2>Process path</h2>
<p><em>Get-Processpath.ps1</em></p>
<p><code>
[cmdletbinding()]<br />
param(<br />
$ComputerName=$env:COMPUTERNAME,<br />
[parameter(Mandatory=$true)]<br />
$ProcessName<br />
)<br />
$Processes = Get-WmiObject -Class Win32_Process -ComputerName $ComputerName -Filter "name='$ProcessName'"<br />
if($Processes) {<br />
foreach ($process in $processes) {<br />
$Executablepath = $process.ExecutablePath<br />
$Commandline = $process.Commandline<br />
$processid = $process.handle<br />
Write-Host ""<br />
Write-Host "Process Name = $ProcessName"<br />
Write-Host "Process ID = $Processid"<br />
Write-Host "Executable Path = $Executablepath"<br />
Write-Host "Command Line = $Commandline"<br />
Write-Host ""<br />
}<br />
} else {<br />
write-host "`nNo Process found with the name $ProcessName"<br />
}
</code></p>
<p>This Powershell script displays the process path.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/12/Process-path.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/12/Process-path.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none;" title="Process path" src="http://4sysops.com/wp-content/uploads/2011/12/Process-path_thumb.png" alt="Process path" width="600" height="225" /></a></p>
<p align="center"><em>Process path</em></p>
<p>Though PowerShell has a built-in cmdlet (Get-Process) to retrieve process information, in all of the above examples I have used a WMI query to get process information from the Win32_Process class. The reason I did so is because Get-Process will not provide the owner, process path, and other values.</p>
<h2>Kill a process</h2>
<p>To terminate a process using PowerShell, you can either use the WMI interface or use the Stop-Process<strong> </strong>cmdlet, which comes by default with PowerShell.</p>
<p><em>Kill-ProcessusingWMI.ps1</em></p>
<p><code>
[cmdletbinding()]<br />
param(<br />
$ComputerName=$env:COMPUTERNAME,<br />
[parameter(Mandatory=$true)]<br />
$ProcessName<br />
)<br />
$Processes = Get-WmiObject -Class Win32_Process -ComputerName $ComputerName -Filter "name='$ProcessName'"<br />
if($processes) {<br />
foreach ($process in $processes) {<br />
$returnval = $process.terminate()<br />
$processid = $process.handle<br />
if($returnval.returnvalue -eq 0) {<br />
    write-host "`nThe process $ProcessName `($processid`) terminated successfully"<br />
}<br />
else {<br />
    write-host "`nThe process $ProcessName `($processid`) termination has some problems"<br />
}<br />
}<br />
} else {<br />
Write-host "`n No processes found with the name $ProcessName"<br />
}<br />
write-host ""
</code></p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/12/Kill-process.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/12/Kill-process.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none;" title="Kill process" src="http://4sysops.com/wp-content/uploads/2011/12/Kill-process_thumb.png" alt="Kill process" width="600" height="143" /></a></p>
<p align="center"><em>Kill a process</em></p>
<p>This script first queries the computer for a list of running processes and then terminates them using the terminate () method. This method will return a value of 0 if the termination is successful. Any non-zero value indicates some issues.</p>
<p>The second method terminates a process using the Stop-Process cmdlet. Below are some usage examples:</p>
<p><code>Get-Process -Name notepad | stop-Process</code></p>
<p><code>Stop-Process -Name notepad</code></p>
<h2>Conclusion</h2>
<p>Querying process information using PowerShell is pretty easy. You can use PowerShell for a variety of purposes, such as reporting application usage, querying the age or the start time of a process, or maximizing, minimizing, or restoring an application window.</p>
Author: Sitaram Pamarthi
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-5-using-powershell-scriptomatic/" title="PowerShell tutorial for admins &#8211; Part 5: Using PowerShell Scriptomatic (July 7, 2011)">PowerShell tutorial for admins &#8211; Part 5: Using PowerShell Scriptomatic</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript vs. PowerShell</title>
		<link>http://4sysops.com/archives/vbscript-vs-powershell/</link>
		<comments>http://4sysops.com/archives/vbscript-vs-powershell/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 19:17:16 +0000</pubDate>
		<dc:creator>Justin Shin</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=6896</guid>
		<description><![CDATA[VBScript vs. PowerShell is the question that many admins face. This article compares VBScript with regard to functionality, performance, compatibility, learning curve, security, and brevity.]]></description>
			<content:encoded><![CDATA[<p><strong><i>VBScript vs. PowerShell is the question that many admins face. This article compares VBScript with regard to functionality, performance, compatibility, learning curve, security, and brevity.</i></strong></p>
<p>VBScript is definitely fading, and PowerShell is rightfully gaining traction, but PowerShell’s learning curve and backwards compatibility issues will keep VBScript around a bit longer.</p>
<p>VBScript was once unquestionably the preferred scripting language of most systems administrators, offering them the ability to automate routine tasks and interact with Windows features like IIS, Active Directory, and Terminal Services. Using the Windows Scripting Host, VBScript performed tasks that the Windows shell (batch scripts) simply could not handle. Then, in 2006, Microsoft released an alternative to VBScript &#8211; and an extension to the basic shell &#8211; known as Windows PowerShell. Since then, VBScript has remained the same while PowerShell 2 has been released.</p>
<p>Of course it’s always nice to have more options. At the same time, the existence of two viable scripting languages poses some new questions for the budding admin. As we compare them head to head, let’s look a bit further into the benefits and drawbacks of each.</p>
<h2>Functionality</h2>
<p>Both VBScript and PowerShell offer similar feature sets. The difference between them is more about how they actually acheive those features, and in most cases, PowerShell takes the cake. VBScript utilizes COM components to access features while PowerShell is built on top of .NET, meaning that it utilizes the base classes and is capable of interacting with some applications (especially Microsoft ones) that cannot be manipulated via VBScript. In fact, the folks who developed Exchange 2007 actually built the <a href="http://blogs.technet.com/b/exchange/archive/2006/09/05/3394830.aspx">entire management console using one-line PowerShell commands</a> (called cmdlets) that do the dirty work for you behind the scenes. Because VBScript is now deprecated and does not respect .NET functionality, it is usually difficult or impossible to manage a .NET application like Exchange via VBScript.</p>
<h2>Performance</h2>
<p>Intuitively, one might think that PowerShell should blow VBScript out of the water in terms of performance given the fact that PowerShell is “integrated” with the kernel and VBScript relies on a COM interpreter. In reality, however, PowerShell and VBScript are <a href="http://www.rlmueller.net/PSVBScript.htm">roughly the same</a> in terms of efficiency. We can speculate about why this would be the case &#8211; perhaps the added overhead of .NET roughly offsets the inefficiency of using COM components &#8211; but the bottom line here is that performance should not be a consideration when choosing between VBScript and PowerShell.</p>
<h2>Compatibility/Deployment Readiness</h2>
<p>The Windows Scripting Host dates back to Windows 98, so VBScript can be deployed to all of your Windows clients “out of the box.” On the other hand, PowerShell was released in 2006 and requires at least Windows XP. More importantly, it is not included in Windows distributions predating Windows Server 2008 and Windows 7, so you will need to deploy and install PowerShell on all of your XP, Vista, and Server 2003 hosts before you can get up and running with it. Perhaps you will want to use a VBScript to automate this process!</p>
<p>In many cases, PowerShell simply cannot perform all of its functions on pre-Windows Server 2008/Windows 7 systems. For example, the Active Directory module &#8211; an important one for most systems admins &#8211; <a href="http://technet.microsoft.com/en-us/library/dd378937(WS.10).aspx">requires Windows 7 and/or Windows Server 2008 R2</a>. This can be a real deal-breaker if your architecture utilizes Windows Server 2003 or XP clients.</p>
<h2>Learning Curve/Existing Scripts</h2>
<p>For starters, we should be clear about one thing: VBScript is a scripting language. While PowerShell can be used for scripting, it is primarily meant to be a shell. So, if you are already familiar with a scripting language or Visual Basic, you might find VBScript quite easy to learn. If you are not a developer and have never used a scripting language before, you might find VBScript a bit harder to learn, but there are still resources and existing script libraries out there to help you get started on your first scripts.</p>
<p>Unless you are already familiar with the .NET base components, you will probably find PowerShell much more difficult to learn. This is not to say that PowerShell is not accessible &#8211; it’s just built on top of a larger framework and thus has a moderate learning curve attached.</p>
<h2>Security</h2>
<p>The Windows Scripting Host has gotten a bad rap over the years for being what Wikipedia terms a “vulnerability vector.” In years past VBScript could be executed through Internet Explorer and bad actors of all varieties would use VBScript to execute code at a high level of system privileges. <a href="http://www.hanselman.com/blog/SigningPowerShellScripts.aspx">PowerShell can use digital signatures</a> (code signing) to prevent execution of malware, something that VBScript does not offer.</p>
<h2><a name="h.gjoctjxjmwp"></a>Brevity</h2>
<p>PowerShell is, in most cases, simply shorter (but often less intelligible) than VBScript. Consider the simple task of renaming all files beginning with “CurrentLog” in their filename to “ArchiveLog:”</p>
<p>First, we have VBScript. We create filesystem objects to access, run a loop to catch the instances of what we are looking for, then use a function to split the filename string up and replace:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/09/VBScript-vs.-PowerShell-VBScript-example.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/09/VBScript-vs.-PowerShell-VBScript-example.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none;" title="VBScript vs. PowerShell - VBScript example" src="http://4sysops.com/wp-content/uploads/2011/09/VBScript-vs.-PowerShell-VBScript-example_thumb.png" alt="VBScript vs. PowerShell - VBScript example" width="484" height="171" /></a></p>
<p><em>VBScript vs. PowerShell &#8211; VBScript example</em></p>
<p>Now, consider this PowerShell cmdlet. Assuming we have already navigated in the shell to the desired folder, we use this slick one-liner to rename the files:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/09/VBScript-vs.-PowerShell-PowerShell-example.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/09/VBScript-vs.-PowerShell-PowerShell-example.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="VBScript vs. PowerShell - PowerShell example" src="http://4sysops.com/wp-content/uploads/2011/09/VBScript-vs.-PowerShell-PowerShell-example_thumb.png" alt="VBScript vs. PowerShell - PowerShell example" width="501" height="31" border="0" /></a></p>
<p><em>VBScript vs. PowerShell &#8211; PowerShell example</em></p>
<p>As you can see, the VBScript example is perhaps more telegraphic, but there’s no debate as to which is shorter (and more elegant).</p>
<h2>The Verdict</h2>
<p>It’s somewhat telling that although VBScript has been in so-called “maintenance mode”- the final step before deprecation &#8211; systems administrators continue to use it today. Perhaps there is a laziness factor. I know that I have scripts in VBScript that I do not want to have to port to PowerShell. PowerShell, despite requiring far fewer lines of code, is far from intuitive. Plus, certain features in PowerShell require Windows 7 or Windows Server 2008 to even work at all.</p>
<p>The <a href="http://dmitrysotnikov.wordpress.com/2008/02/15/powershell-adoption-by-platform/">smart money is that PowerShell will be the Microsoft-platform automation language</a> once Windows 7 and Server 2008 gain widespread use, and most would say that PowerShell has already become the scripting (and shell) language of choice in the Microsoft world. But, if PowerShell cannot play nicely with your existing architecture and needs, VBScript is still the way to go.</p>
Author: Justin Shin
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-5-using-powershell-scriptomatic/" title="PowerShell tutorial for admins &#8211; Part 5: Using PowerShell Scriptomatic (July 7, 2011)">PowerShell tutorial for admins &#8211; Part 5: Using PowerShell Scriptomatic</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/vbscript-vs-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</title>
		<link>http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/</link>
		<comments>http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 20:40:16 +0000</pubDate>
		<dc:creator>Timothy Warner</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=6431</guid>
		<description><![CDATA[In this article you will learn how to manage Windows Server 2008 roles and features by using Windows PowerShell.]]></description>
			<content:encoded><![CDATA[<p><strong><i>In this article you will learn how to manage Windows Server 2008 roles and features by using Windows PowerShell.</i></strong></p>
<p>This is the sixth part of the Windows PowerShell series. PowerShell beginners should also read the <a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-1-cmdlets-and-pipeline/">previous parts</a>.</p>
<p>In Windows Server 2008 a <em>server</em> <em>role</em> represents an installable unit of functionality that defines the primary function of a server. For instance, you may install Active Directory Domain Services (AD DS) to create a dedicated domain controller for your forest.</p>
<p>By contrast, Windows Server 2008 <em>features</em> are a bit more slippery to define. Like a server role, a feature is an installable unit of functionality. However, whereas a server role typically defines the chief duty of a server, a feature (at least according to Microsoft marketing literature) “provides auxiliary or supporting functions” within a system. Thus, a single server may be the holder of several features.</p>
<p>As you probably already know, you can manage server roles and features by using any of the following tools:</p>
<ul>
<li><strong>ServerManagerCmd.exe</strong></li>
<li>Server Manager console</li>
<li>Windows PowerShell</li>
</ul>
<p>You also may know that, as of Windows Server 2008 R2, the <strong>ServerManagerCmd.exe</strong> command-line tool is formally deprecated (read: does not work anymore); you are instead politely “encouraged” to use Windows PowerShell instead. In this article we will learn how to leverage the Windows PowerShell scripting and automation environment to install, administer, and remove server roles and features.</p>
<h2>Installing Windows PowerShell 2.0</h2>
<p>The first order of business is ensuring that your target Windows Server 2008 computers have Windows PowerShell 2.0 installed. If you are running Windows Server 2008 RTM, then you can use the <strong>ServerManagerCmd.exe</strong> utility to install Windows PowerShell:</p>
<p><strong>OS&gt;ServerManagerCmd –install PowerShell</strong></p>
<p>If you run Windows Server 2008 R2, then you already have Windows PowerShell 2.0 installed. To verify your installed Windows PowerShell version, open an elevated command prompt, issue the command <strong>powershell</strong> to start a Windows PowerShell session, and then invoke the <strong>$Host.Version</strong> method. All of these commands are depicted in the following exhibit:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/Verifying-PowerShell.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/Verifying-PowerShell.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Verifying PowerShell" src="http://4sysops.com/wp-content/uploads/2011/07/Verifying-PowerShell_thumb.png" border="0" alt="Verifying PowerShell" width="604" height="390" /></a></p>
<p><em>Verifying Windows PowerShell</em></p>
<p><strong>NOTE</strong>: There is a world of difference between Windows PowerShell v1.0 and v2.0. Please ensure that you are running PowerShell v2.0, and be certain to run Windows Update to download the latest enhancements to the technology.</p>
<h2>Installing a Role or Feature</h2>
<p>As far as I am personally concerned, it is a blessing that Windows PowerShell does not try to split hairs and differentiate server roles and features. As you will see momentarily, all roles and features appear in a single master list.</p>
<p>From an administrative command prompt, fire up Windows PowerShell and issue the cmdlet <strong>Import-Module Servermanager</strong> to load the Server Manager PowerShell module.</p>
<p>Next, run the cmdlet <strong>Get-WindowsFeature</strong> to see a tree list of all available server roles and features. Any roles or features that are currently installed will appear with an X within the selection brackets. Pay particular attention to the role and feature short names in the <strong>Name</strong> column, as shown in the below screenshot; we will need those IDs to perform the next step.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/Listing-available-server-roles-and-features-with-PowerShell.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/Listing-available-server-roles-and-features-with-PowerShell.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Listing available server roles and features with PowerShell" src="http://4sysops.com/wp-content/uploads/2011/07/Listing-available-server-roles-and-features-with-PowerShell_thumb.png" border="0" alt="Listing available server roles and features with PowerShell" width="604" height="368" /></a></p>
<p><em>Listing available server roles and features</em></p>
<p><strong>NOTE</strong>: In Windows PowerShell nomenclature, a <em>module</em> is a self-contained, reusable library of related PowerShell functionality. Most Microsoft server technologies, such as SQL Server 2008, SharePoint Server 2010, and Exchange Server 2010, ship with their own custom modules to enable administrators to use PowerShell with those products.</p>
<p>We use the <strong>Add-WindowsFeature</strong> cmdlet to install both server roles and features. To leverage this cmdlet, we simply pass a comma-separated list of either display names (in quotes) or short names for the roles and/or features you wish to install.</p>
<p><strong>PS&gt;Add-WindowsFeature role, feature, etc.</strong></p>
<p>See the following exhibit for an interface example in which we install the File Server, Domain Name System (DNS), and Dynamic Host Configuration Protocol (DHCP) server roles on a Windows Server 2008 R2 server.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/Installing-roles-and-features-with-PowerShell.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/Installing-roles-and-features-with-PowerShell.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Installing roles and features with PowerShell" src="http://4sysops.com/wp-content/uploads/2011/07/Installing-roles-and-features-with-PowerShell_thumb.png" border="0" alt="Installing roles and features with PowerShell" width="604" height="369" /></a></p>
<p><em>Installing roles and features</em></p>
<p>To verify that the new server roles have been installed successfully, let’s fire up Server Manager and have a look at the <strong>Roles</strong> tree:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/Verifying-server-role-installation-with-PowerShell.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/Verifying-server-role-installation-with-PowerShell.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Verifying server role installation with PowerShell" src="http://4sysops.com/wp-content/uploads/2011/07/Verifying-server-role-installation-with-PowerShell_thumb.png" border="0" alt="Verifying server role installation with PowerShell" width="592" height="413" /></a></p>
<p><em>Verifying server role installation</em></p>
<p>Ah, success!</p>
<h2>Removing a Role or Feature</h2>
<p>Removing Windows Server 2008 roles and features by using PowerShell is an equally simple procedure. To do this, we invoke the <strong>Remove-WindowsFeature</strong> cmdlet. You can throw in the optional <strong>–restart</strong> parameter to specify an automatic server restart if Windows needs to do so.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/Removing-server-roles-with-PowerShell.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/Removing-server-roles-with-PowerShell.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Removing server roles with PowerShell" src="http://4sysops.com/wp-content/uploads/2011/07/Removing-server-roles-with-PowerShell_thumb.png" border="0" alt="Removing server roles with PowerShell" width="604" height="368" /></a></p>
<p><em>Removing server roles</em></p>
<p>One word of warning: If you do elect to add the <strong>–restart</strong> parameter to your cmdlet, the server will restart (if necessary) with absolutely no timeout or other warning. It just goes!</p>
<h2>Conclusion</h2>
<p>At this point you should be able to manage Windows Server 2008 roles and features by using PowerShell. I will leave you with some related study resources if you are so inclined. I hope that you found this article helpful. Thanks!</p>
<p><strong><span style="text-decoration: underline;">For Further Study:</span></strong></p>
<ul>
<li><a href="http://technet.microsoft.com/en-us/library/cc732263.aspx">Adding Server Roles and Features</a></li>
<li><a href="http://blogs.technet.com/b/stefan_stranger/archive/2011/01/27/checking-server-roles-when-installing-opsmgr-2010-ctp2-with-powershell.aspx">Checking Server Roles with PowerShell</a></li>
<li><a href="http://www.microsoft.com/windowsserver2008/en/us/server-management.aspx">Windows Server 2008 Server Management</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/bb978526.aspx">Windows PowerShell</a></li>
</ul>
Author: Timothy Warner
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-5-using-powershell-scriptomatic/" title="PowerShell tutorial for admins &#8211; Part 5: Using PowerShell Scriptomatic (July 7, 2011)">PowerShell tutorial for admins &#8211; Part 5: Using PowerShell Scriptomatic</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[PowerShell Tutorial]]></series:name>
	</item>
		<item>
		<title>PowerShell tutorial for admins &#8211; Part 5: Using PowerShell Scriptomatic</title>
		<link>http://4sysops.com/archives/powershell-tutorial-for-admins-part-5-using-powershell-scriptomatic/</link>
		<comments>http://4sysops.com/archives/powershell-tutorial-for-admins-part-5-using-powershell-scriptomatic/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 21:30:49 +0000</pubDate>
		<dc:creator>Timothy Warner</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=6380</guid>
		<description><![CDATA[In this article you will learn how to use PowerShell Scriptomatic to perform WMI system administration by using Windows PowerShell.]]></description>
			<content:encoded><![CDATA[<p><strong><i>In this article you will learn how to use PowerShell Scriptomatic to perform WMI system administration by using Windows PowerShell.</i></strong></p>
<p>This is the fifth installment of a multi-part series on Windows PowerShell for Windows systems administrators. To become current with our subject matter, I encourage you to read the four previous articles of this <a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-1-cmdlets-and-pipeline/">PowerShell tutorial</a>.</p>
<p>As we discussed in a previous entry in this series, learning the syntax of the <a href="http://msdn.microsoft.com/en-us/library/aa392902.aspx">WMI Query Language</a> (WQL) is tough enough without having the understand the <a href="http://technet.microsoft.com/library/ee176860.aspx">WMI-related PowerShell cmdlets</a> as well. In this essay I will introduce you to the nifty Microsoft PowerShell Scriptomatic utility. By the conclusion of this piece you will be integrating WMI and PowerShell with the best of ‘em!</p>
<p>Let’s get right to work.</p>
<h2>Preliminary Terminology</h2>
<p>As usual, we need to define our terms. By way of review, recall that <a href="http://msdn.microsoft.com/en-us/library/aa384642%28v=vs.85%29.aspx">Windows Management Instrumentation (WMI)</a> is Microsoft’s implementation of Web-Based Enterprise Management (<a href="http://www.dmtf.org/standards/wbem">WBEM</a>), which in turn uses the Common Information Model (<a href="http://www.dmtf.org/standards/cim">CIM</a>) standard to define access methods for computers, networks, applications, and so forth. Think of WMI and WBEM as the next generation of the <a href="http://whatsup.custhelp.com/cgi-bin/whatsup.cfg/php/enduser/std_adp.php?p_faqid=84&amp;p_created=1219177528&amp;p_topview=1">Simple Network Management Protocol (SNMP)</a>.</p>
<p>In WMI, managed system information, including hardware and software-related data, is reported by using <em>schemas</em>. We employ the CIM schemas to access WMI classes, which in turn represent the specific data elements that we wish to query.</p>
<p>A WMI <em>namespace</em> is a subsection of the CIM repository. The most commonly used WMI namespace (and the one we will reference in this tutorial) is named <strong>root\CIMV2</strong>. The <strong>root\CIMV2</strong> namespace ncludes an enormous number of Windows-related classes; lots of rich information in there!</p>
<p><strong> </strong></p>
<p>Please see the following sources for a complete list of WMI namespaces and classes:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa394572%28v=VS.85%29.aspx">MSDN: WMI Reference</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa394554%28v=vs.85%29.aspx">MSDN: WMI Classes</a></li>
</ul>
<p>If you prefer the long way (that is, the manual way) around WMI systems administration, you can leverage the PowerShell <strong>Get-WMIObject</strong> cmdlet as well as your existing knowledge of WQL syntax to do your work. For instance, issue the following statement from a PowerShell prompt to return a list of all available WMI namespaces on the local system:</p>
<p>PS&gt;Get-WMIObject –namespace “root” –query “SELECT * FROM __Namespace” | Select Name</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Listing-WMI-name-spaces.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Listing-WMI-name-spaces.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="PowerShell tutorial -  Listing WMI name spaces" src="http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Listing-WMI-name-spaces_thumb.png" border="0" alt="PowerShell tutorial -  Listing WMI name spaces" width="604" height="281" /></a></p>
<p><em>Listing WMI namespaces from PowerShell</em></p>
<p>However, if you would prefer a bit of automation in your life with respect to WMI and PowerShell, then look no further than the PowerShell Scriptomatic tool. Read on, friends!</p>
<h2>Introducing PoweShell Scriptomatic</h2>
<p><a href="http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&amp;id=12028">Scriptomatic v2</a> is a GUI utility developed by the <a href="http://technet.microsoft.com/en-us/scriptcenter/dd901334">Microsoft Scripting Guys</a> and has as its goal the easier creation of WMI scripts for system administration.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/Scriptomatic-2.0.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/Scriptomatic-2.0.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Scriptomatic 2.0" src="http://4sysops.com/wp-content/uploads/2011/07/Scriptomatic-2.0_thumb.png" border="0" alt="Scriptomatic 2.0" width="604" height="462" /></a></p>
<p><em>Scriptomatic 2.0</em></p>
<p>As you may or may not be able to tell from Figure 2, the use of Scriptomatic involves the following workflow:</p>
<ol>
<li>Select your desired WMI namespace and WMI class. The tool helpfully defaults to <strong>root\CIMV2</strong>.</li>
<li>Choose appropriate scripting language and output format. Supported languages are VBScript, Perl, Jscript, and Python, and supported outputs are command prompt, plain text, HTML, Excel, and XML.</li>
<li>Select the target computer(s) for the script</li>
<li>Use the toolbar buttons to execute the script immediately, save the script to disk, etc.</li>
</ol>
<p>Scriptomatic is a pretty awesome utility, isn’t it? However, unless you (a) are already proficient in VBScript or Jscript; or (b) already have the Perl and/or Python interpreters installed on your system, this tool is of limited use. After all, we are budding PowerShell scripters, correct?</p>
<p>Fortunately for us, the Microsoft Scripting Guys authored a <a href="http://technet.microsoft.com/en-us/library/ff730935.aspx">PowerShell edition of Scriptomatic</a>. You can’t beat the price, either: both Scriptomatic tools are free for your downloading pleasure!</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/Scriptomatic-PowerShell-edition.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/Scriptomatic-PowerShell-edition.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Scriptomatic PowerShell edition" src="http://4sysops.com/wp-content/uploads/2011/07/Scriptomatic-PowerShell-edition_thumb.png" border="0" alt="Scriptomatic PowerShell edition" width="604" height="430" /></a></p>
<p><em>Scriptomatic PowerShell edition</em></p>
<p>Note that the workflow for the PowerShell edition of Scriptomatic is essentially identical to that of Scriptomatic V2:</p>
<ol>
<li>Select your desired WMI namespace and class</li>
<li>Specify one or more target computers (comma-separated list; you can load this from an external file)</li>
<li>Use the Control Pad buttons to specify output options</li>
</ol>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/Scriptomatic-PowerShell-output.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/Scriptomatic-PowerShell-output.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Scriptomatic PowerShell output" src="http://4sysops.com/wp-content/uploads/2011/07/Scriptomatic-PowerShell-output_thumb.png" border="0" alt="Scriptomatic PowerShell output" width="604" height="429" /></a></p>
<p><em>Scriptomatic PowerShell output</em></p>
<p>Check out the output in Figure 4; these expressions should look familiar to you if you’ve been keeping up on the content in this series. In this example we have variables and an invocation of the <strong>Get-WMIObject</strong> PowerShell cmdlet.</p>
<p>Following is a brief summary of the functionality of the Control Pad buttons:</p>
<ul>
<li><strong>Run</strong>: Executes the current code in a command prompt window</li>
<li><strong>Save</strong>: Enables you to save your work as a <strong>.PS1</strong> script file</li>
<li><strong>Clear Script</strong>: Clears the work area</li>
<li><strong>Refresh Script</strong>: Updates the active script to reflect any changes</li>
<li><strong>Notepad</strong>: Opens your work in a new Notepad file</li>
<li><strong>Open Temp File</strong>: Opens a blank file in Notepad</li>
</ul>
<p>Hey, one more trick for you: Click the third toolbar button (for some inexplicable reason the Microsoft Scripting Guys have not differentiated these button icons!) and click <strong>Display Class Properties. </strong>Next, from the Control Pad, click <strong>Refresh Script</strong>. You now can drill into the granular data elements (aka properties) within the selected class. This procedure is shown in Figure 5:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/Accessing-class-properties-in-Scriptomatic.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/Accessing-class-properties-in-Scriptomatic.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="Accessing class properties in Scriptomatic" src="http://4sysops.com/wp-content/uploads/2011/07/Accessing-class-properties-in-Scriptomatic_thumb.png" border="0" alt="Accessing class properties in Scriptomatic" width="604" height="429" /></a></p>
<p><em>Accessing class properties in Scriptomatic</em></p>
<h2>Conclusion</h2>
<p>Alrighty then! By now I think that you have a flying head start at using both WMI and PowerShell in your Windows systems administration work. I hope that you found this article helpful.</p>
<p>In the next installment of this series we will examine how to manage Windows Server 2008 roles and features by using PowerShell. Take care, and thanks for reading.</p>
Author: Timothy Warner
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/powershell-tutorial-for-admins-part-5-using-powershell-scriptomatic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[PowerShell Tutorial]]></series:name>
	</item>
		<item>
		<title>PowerShell tutorial for admins &#8211; Part 4: Obtaining server metadata</title>
		<link>http://4sysops.com/archives/powershell-tutorial-for-admins-part-4-obtaining-server-metadata/</link>
		<comments>http://4sysops.com/archives/powershell-tutorial-for-admins-part-4-obtaining-server-metadata/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 21:20:45 +0000</pubDate>
		<dc:creator>Timothy Warner</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=6342</guid>
		<description><![CDATA[In this article you will learn how to leverage PowerShell to obtain system information in Windows Server 2008 and Windows desktop systems.]]></description>
			<content:encoded><![CDATA[<p><strong><i>In this article you will learn how to leverage PowerShell to obtain system information in Windows Server 2008 and Windows desktop systems.</i></strong></p>
<p>This is the fourth installment of a multi-part series on Windows PowerShell for Windows systems administrators. To get caught up on our subject matter, you might want to read the three previous article about <a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-1-cmdlets-and-pipeline/">cmdlets and pipeline</a>, <a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-2-aliases-and-drives/">aliases and drives</a>, and <a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-3-run-a-powershell-script/">running scripts</a>.</p>
<p>Now that we have a preliminary understanding of Windows PowerShell, it is time to turn our attention to practical application of the technology. To wit, in this blog post we will learn how to leverage PowerShell in order to ascertain <a href="http://en.wikipedia.org/wiki/Metadata">metadata</a> (that is to say, data about data) from a Windows Server 2008 computer. Of course, the same cmdlets apply for obtaining metadata from Windows client machines as well. Let’s get to work!</p>
<h2>Preliminary Terminology</h2>
<p>Before we begin, it is imperative that we have our terminology down pat. First, let’s define environment variables and WMI. <a href="http://msdn.microsoft.com/en-us/library/ms682653%28v=vs.85%29.aspx">According to Microsoft</a>, an <em>environment variable</em> is “a string that contains information about the environment for the system, and the currently logged on user.”</p>
<p>In current Windows systems, the traditional ways to access environment variables are either through the <strong>System</strong> Control Panel item or the <strong>SET</strong> command-line program.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Server-metadata-2.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Server-metadata-2.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="PowerShell tutorial Server metadata Environment variables" src="http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Server-metadata-2_thumb.png" border="0" alt="PowerShell tutorial Server metadata Environment variables" width="604" height="440" /></a></p>
<p><em>Accessing environment variables in Windows</em></p>
<p><a href="http://en.wikipedia.org/wiki/Windows_Management_Instrumentation">Wikipedia</a> defines <em>Windows Management Instrumentation</em> (WMI) as “a set of extensions to the Windows Driver Model that provides an operating system interface through which instrumented components provide information and notification.”</p>
<p>In Windows Server 2008, we use WMI not only to discover computer metadata, but we can also create employ WMI for local and remote system administration. In addition, we can define WMI filters in Group Policy to target Group Policy Objects (GPOs) based upon hardware and software-specific criteria.</p>
<h2>Accessing Environment Variables in PowerShell</h2>
<p>To begin with, fire up an administrative command prompt and type <strong>powershell</strong> to enter the PowerShell v2 environment. Next, issue the following command to return a list of all defined environment variables for the system:</p>
<p><em>PS&gt;dir Env:</em></p>
<p><strong>NOTE</strong>: You might recall that <strong>dir</strong> represents an alias for the <strong>Get-ChildItem</strong> cmdlet, and that <strong>Env:</strong> represents a PowerShell drive. See the earlier installments of this series for more information.</p>
<p>To query the value of an existing environment variable, use the following syntax:</p>
<p><em>PS&gt;$Env:&lt;variable_name&gt;</em></p>
<p>Here is a nice list of examples to get you started:</p>
<ul>
<li>$env:username (Displays the name of the currently logged-on user)</li>
<li>$env:userdomain (Displays the logon domain for the current user)</li>
<li>$env:computername (Displays the hostname of the local system)</li>
<li>$env:os (Displays the operating system kernel name)</li>
<li>$env:path (Displays the search path for executable files)</li>
</ul>
<p>Some PowerShell cmdlets, specifically those that access and modify system information for local and remote systems, require authentication credentials.</p>
<p>We can define a PowerShell variable, for instance $cred1, and instantiate an instance of the <strong>Get-Credential</strong> cmdlet. That is:</p>
<p><em>PS&gt;$cred = Get-Credential</em></p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Server-metadata-Storing-Credentials.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Server-metadata-Storing-Credentials.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="PowerShell tutorial - Server metadata - Storing Credentials" src="http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Server-metadata-Storing-Credentials_thumb.png" border="0" alt="PowerShell tutorial - Server metadata - Storing Credentials" width="604" height="272" /></a></p>
<p><em>Storing a credential in PowerShell</em></p>
<p>Do you see what’s going on here? The PowerShell script author is prompted for those credentials, which can then be used later on in an interactive session or PowerShell script file.</p>
<p>For greater flexibility, we can hard-code a credential:</p>
<p><em>PS&gt;$cred2 = Get-Credential –credential corpdomain\admin</em></p>
<p>In this case, you are prompted for the password and PowerShell stores the password as an encrypted string, safe and secure. We can then call the password later in our PowerShell script or interactive session like so:</p>
<p><em>PS&gt; $user2 = $cred2.username</em></p>
<p><em>$pw = $cred2.password</em></p>
<p>Now let’s link our understanding of stored credentials with the magic of WMI.</p>
<p>Obtaining System Information in PowerShell</p>
<p>If you have ever tried to use WMI before, you doubtless have found that the WMI Query Language (WQL) used to perform these actions is a bit obtuse. Okay, maybe more than a bit obtuse. Yes, WQL is a subset of the Structured Query Language (SQL) that we database administrators know and love, but the syntax is just so non-intuitive!</p>
<p>Regardless, let’s dive right in with some examples:</p>
<p><em>PS&gt;Get-WMIObject –Class Win32_ComputerSystem</em></p>
<p>The above statement lists detailed information about one or more target computers. We can extend that statement big-time by adding additional computer names and attaching our previously defined credential:</p>
<p><em>PS&gt;Get-WMIObject –Class Win32_ComputerSystem –ComputerName server01, server02, host144, host 255 –Credential $cred1</em></p>
<p>You can also use this same syntax, substituting only the specific WMI objects to be retrieved. To wit:</p>
<ul>
<li>Win32_OperatingSystem (Detailed OS metadata)</li>
<li>Win32_UserAccount (Lists user accounts)</li>
<li>Win32_Group (Lists groups)</li>
</ul>
<p><a href="http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Enumerating-Windows-groups.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Enumerating-Windows-groups.png','',event,300,75)"><img style="background-image: none; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border: 0px;" title="PowerShell tutorial - Enumerating Windows groups" src="http://4sysops.com/wp-content/uploads/2011/07/PowerShell-tutorial-Enumerating-Windows-groups_thumb.png" border="0" alt="PowerShell tutorial - Enumerating Windows groups" width="604" height="279" /></a></p>
<p><em>Enumerating Windows groups with PowerShell</em></p>
<h2>Conclusion</h2>
<p>In a future installment of this series I will share with you some tools that will make your PowerShell WMI querying a much more painless process. In the meantime, please feel free to leave your questions, comments, and suggestions for new topics in the comments. Thanks for reading and take care!</p>
<p><strong><span style="text-decoration: underline;">For Further Study:</span></strong></p>
<ul>
<li><a href="http://technet.microsoft.com/en-us/library/ff730964.aspx">Creating and Modifying Environment Variables</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/dd347713.aspx">About Environment Variables</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa394572%28v=vs.85%29.aspx">WMI Reference</a></li>
<li><a href="http://blogs.msdn.com/b/powershell/archive/2009/08/30/exploring-wmi-with-powershell-v2.aspx">Exploring WMI with PowerShell V2</a></li>
</ul>
Author: Timothy Warner
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/powershell-tutorial-for-admins-part-4-obtaining-server-metadata/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<series:name><![CDATA[PowerShell Tutorial]]></series:name>
	</item>
		<item>
		<title>PowerShell tutorial for admins &#8211; Part 3: Run a PowerShell script</title>
		<link>http://4sysops.com/archives/powershell-tutorial-for-admins-part-3-run-a-powershell-script/</link>
		<comments>http://4sysops.com/archives/powershell-tutorial-for-admins-part-3-run-a-powershell-script/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 15:42:15 +0000</pubDate>
		<dc:creator>Timothy Warner</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=6280</guid>
		<description><![CDATA[In this article you will learn the basics of running PowerShell script files.]]></description>
			<content:encoded><![CDATA[<p><strong><i>In this article you will learn the basics of running PowerShell script files.</i></strong></p>
<p>This is the third installment of a multi-part series on Windows PowerShell for Windows systems administrators. To get caught up on our subject matter, you might want to read the two previous articles about <a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-1-cmdlets-and-pipeline/">cmdlets and the pipeline</a> and about <a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-2-aliases-and-drives/">aliases and drives</a>.</p>
<p>Now, then—on with the show. While issuing ad-hoc PowerShell cmdlets from a PowerShell prompt is all well and good for occasional or on-demand use, you don’t truly begin to leverage the strengths of Windows PowerShell until you aggregate your code (which can include variables, branching, looping, error handling, etc.) into script files.</p>
<p>In a future installment we will begin to drill into practical examples of administering Windows using PowerShell. In this essay I will teach you the basics of creating and running PowerShell scripts from an overview perspective.</p>
<h2>What is a PowerShell script?</h2>
<p>A Windows PowerShell script file is nothing more than a plain text file that (a) has the .ps1 file extension; and (b) contains one or more lines of PowerShell source code.</p>
<p>Plaintext script file</p>
<p>Like VBScript, Python, and most other so-called “scripting languages,” your code is not compiled at run-time but is rather interpreted, line-by-line, by the PowerShell interpreter.</p>
<p>Therefore, you will get exactly nowhere unless and until you have PowerShell 2.0 installed on your target system. When you <a href="http://support.microsoft.com/kb/968929">download PowerShell 2.0</a> (wonkily called the Windows Management Framework by Microsoft), you not only receive the PowerShell runtime environment, but you also receive the PowerShell Integrated Scripting Environment (ISE).</p>
<p>The ISE is a graphical interface (specifically a host application) for Windows PowerShell, and in my opinion should be your de facto scripting environment.</p>
<p><em><strong>NOTE</strong>: In PowerShell nomenclature, a host application is a management tool that includes the Windows PowerShell runtime within its framework. For instance, the Microsoft Exchange Administrator console is a PowerShell host application, as are all third-party PowerShell ISEs</em>.</p>
<p>The following exhibit shows the unique, three-paned interface of the PowerShell ISE:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/06/Running.a.PowerShell.script.The_.Windows.PowerShell.ISE_.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/06/Running.a.PowerShell.script.The_.Windows.PowerShell.ISE_.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="Running a PowerShell script - The Windows PowerShell ISE" src="http://4sysops.com/wp-content/uploads/2011/06/Running.a.PowerShell.script.The_.Windows.PowerShell.ISE_thumb.png" border="0" alt="Running a PowerShell script - The Windows PowerShell ISE" width="604" height="494" /></a></p>
<p><em>The Windows PowerShell ISE</em></p>
<p>The three viewing panes have the following purpose:</p>
<ul>
<li><strong>Script Pane</strong>: Enables you to edit your PowerShell scripts</li>
<li><strong>Output Pane</strong>: Displays the output from your scripts</li>
<li><strong>Command Pane</strong>: Enables you to issue PowerShell statements interactively</li>
</ul>
<p>While we’re at it, in the name of completeness why don’t we briefly explain the function of the primary toolbar buttons as well:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/06/Run.PowerShell.Script.The_.PowerShell.ISE_.toolbar.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/06/Run.PowerShell.Script.The_.PowerShell.ISE_.toolbar.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="Run.PowerShell.Script.The.PowerShell.ISE.toolbar" src="http://4sysops.com/wp-content/uploads/2011/06/Run.PowerShell.Script.The_.PowerShell.ISE_.toolbar_thumb.png" border="0" alt="Run.PowerShell.Script.The.PowerShell.ISE.toolbar" width="554" height="111" /></a></p>
<p><em>Figure 2: The PowerShell ISE toolbar</em></p>
<ul>
<li>1: New</li>
<li>2: Open</li>
<li>3: Save</li>
<li>4: Cut</li>
<li>5: Copy</li>
<li>6: Paste</li>
<li>7: Clear Output Pane</li>
<li>8: Undo</li>
<li>9: Redo</li>
<li>10: Run Script</li>
<li>11: Run Selection</li>
<li>12: Stop Execution</li>
<li>13: New Remote PowerShell Tab</li>
<li>14: Start PowerShell.exe</li>
<li>15: Show Script Pane Top</li>
<li>16: Show Script Pane Right</li>
<li>17: Show Script Pane Maximized</li>
</ul>
<h2>Creating a PowerShell script</h2>
<p>Authoring a Windows PowerShell script is as easy as typing or pasting your code into the ISE script pane and then pressing the <strong>Run Script</strong> toolbar button. Be sure to save your file with the <strong>.ps1</strong> extension; the PowerShell ISE takes care of that pesky little detail for you.</p>
<p>If you are a beginner to PowerShell scripting, then you will want to (1) purchase a great textbook or computer-based training course on the subject; and (2) make use of the wonderful <a href="http://gallery.technet.microsoft.com/scriptcenter/site/search?f%5b0%5d.Type=ScriptLanguage&amp;f%5b0%5d.Value=PowerShell&amp;f%5b0%5d.Text=PowerShell">Microsoft TechNet Script Repository</a>.</p>
<p>In point of fact, the <a href="http://gallery.technet.microsoft.com/scriptcenter/cc94d4ab-44c6-45a4-abf4-3e28b0429f15">simple PowerShell script</a> we use as an example in this article was borrowed from the TechNet Script Repository.</p>
<h2>Running a PowerShell script</h2>
<p>Before we learn how to run a PowerShell script from outside the ISE, we need to explain PowerShell execution policy, formally defined as Code Access Security.</p>
<p>By default, Windows PowerShell runs in the <strong>Restricted</strong> execution policy, which means that Windows PowerShell can be used only in interactive mode from a PowerShell prompt or from an ISE. This prohibition of PowerShell scripts from running “free” on a host system was done by design and obviously for security purposes.</p>
<p>The other three PowerShell execution policies are:</p>
<ul>
<li><strong>AllSigned</strong>: Only scripts that are digitally signed by a trusted publisher are allowed to run</li>
<li><strong>RemoteSigned</strong>: Locally created scripts can run fine; downloaded scripts must be digitally signed by a trusted publisher in order to run</li>
<li><strong>Unrestricted</strong>: All PowerShell scripts can run without restriction (not recommended for most environments)</li>
</ul>
<p>To change the PowerShell script execution policy on a system, open an elevated command prompt, start PowerShell by typing <strong>powershell</strong>, and then invoke the <strong>Set-ExecutionPolicy</strong> cmdlet. To verify the current execution policy, run <strong>Get-ExecutionPolicy</strong>.</p>
<p>The following exhibit demonstrates how to both verify the current execution policy, as well as how to change the default execution policy to something a bit more reasonable in a development environment—RemoteSigned.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/06/Run.PowerShell.Script.Setting.Windows.PowerShell.execution.policy.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/06/Run.PowerShell.Script.Setting.Windows.PowerShell.execution.policy.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="Run.PowerShell.Script.Setting.Windows.PowerShell.execution.policy" src="http://4sysops.com/wp-content/uploads/2011/06/Run.PowerShell.Script.Setting.Windows.PowerShell.execution.policy_thumb.png" border="0" alt="Run.PowerShell.Script.Setting.Windows.PowerShell.execution.policy" width="604" height="325" /></a></p>
<p><em>Setting Windows PowerShell execution policy</em></p>
<p>Now for the good stuff. To run a PowerShell script from an elevated command prompt, perform one of the following actions:</p>
<ul>
<li>.\&lt;script&gt;.ps1 (You can use this form if your OS prompt is already focused in the local directory that contains the target PowerShell script file)</li>
<li>C:\Scripts\&lt;script.ps1&gt; (Here we specify the fully qualified filename of the target PowerShell script)</li>
</ul>
<p>As long as Windows is properly configured to associate the <strong>.ps1</strong> extension with Windows PowerShell, the inclusion of the file extension in your scripts is optional.</p>
<p>If, by contrast, you are already within PowerShell, you can employ the <strong>Invoke-Expression</strong> cmdlet to run the script. To wit:</p>
<p><em>PS&gt; Invoke-Expression “C:\Scripts\&lt;script&gt;.ps1”</em></p>
<p><strong>NOTE</strong>: The use of quotation marks is required only if your directory path includes spaces. Be aware, also, that by default you must always fully qualify the location of the script file even if your present working directory is the same location as the target script.</p>
<p>Finally, you can use the ampersand (&amp;) shortcut to run a script from within PowerShell. That is to say:</p>
<p><em>PS&gt;&amp; “C:\Scripts\&lt;script&gt;.ps1”</em></p>
<h1>Conclusion</h1>
<p>At this point you know a thing or two about creating and running Windows PowerShell scripts. I will leave you with some helpful links to foster further learning. If there are other PowerShell-related topics on which you would like to see coverage here at 4Sysops, then please feel free to leave those requests in the comments portion of this post.</p>
<p><strong><span style="text-decoration: underline;">For Further Study:</span></strong></p>
<ul>
<li><a href="http://technet.microsoft.com/en-us/library/cc764242.aspx">Running Scripts</a></li>
<li><a href="http://stackoverflow.com/questions/171514/best-ide-for-powershell">Best IDE for PowerShell?</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/dd315244.aspx">Introducing the Windows PowerShell ISE</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/ee221100.aspx">Windows PowerShell Owner’s Manual</a></li>
<li><a href="http://www.amazon.com/Windows-PowerShell-Administrators-Pocket-Consultant/dp/0735625956/ref=sr_1_2?ie=UTF8&amp;qid=1308178042&amp;sr=8-2">Windows PowerShell 2.0 Administrator’s Pocket Consultant</a></li>
</ul>
Author: Timothy Warner
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/powershell-tutorial-for-admins-part-3-run-a-powershell-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[PowerShell Tutorial]]></series:name>
	</item>
		<item>
		<title>PowerShell tutorial for admins &#8211; Part 2: Aliases and drives</title>
		<link>http://4sysops.com/archives/powershell-tutorial-for-admins-part-2-aliases-and-drives/</link>
		<comments>http://4sysops.com/archives/powershell-tutorial-for-admins-part-2-aliases-and-drives/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 19:34:10 +0000</pubDate>
		<dc:creator>Timothy Warner</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=6248</guid>
		<description><![CDATA[Part 2 of the PowerShell tutorial for Windows admins  introduces aliases and drives.]]></description>
			<content:encoded><![CDATA[<p><strong><i>Part 2 of the PowerShell tutorial for Windows admins  introduces aliases and drives.</i></strong></p>
<p>In the first part of this miniseries on Windows PowerShell terminology for administrators we briefly <a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-1-cmdlets-and-pipeline/">described what PowerShell is an introduced you to the cmdlet and the pipeline</a>.</p>
<p>Let’s now continue our journey by learning two additional core terms that every PowerShell scripter should know.</p>
<h2>Aliases</h2>
<p>One of the things that I really love about Windows PowerShell is how much thought the Microsoft developers put into making the environment as user-friendly for existing Windows (and even *NIX) scripters as possible. To me, aliases represent the best example of this universality aspect of Windows PowerShell.</p>
<p>For instance, recall how earlier in this article I told you that the <strong>Get-ChildItem</strong> cmdlet is analogous in functionality to the Windows <strong>dir</strong> command? Well, as it happens, you can use <strong>dir</strong> all day long to retrieve directory listings in PowerShell. Are you a Mac or a NIX scripter? No problem—try using <strong>ls</strong>. It works!</p>
<p>In PowerShell, an <a href="http://technet.microsoft.com/en-us/library/ee692685.aspx">alias</a> is nothing more than a persistent mapping of a system- or user-defined shortcut to a known PowerShell cmdlet.</p>
<p>To obtain a full list of built-in aliases, simply invoke the cmdlet <strong>Get-Alias</strong> from your PowerShell environment.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/06/PowerShell.Tutorial.Aliases.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/06/PowerShell.Tutorial.Aliases.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="PowerShell Tutorial - Aliases" src="http://4sysops.com/wp-content/uploads/2011/06/PowerShell.Tutorial.Aliases_thumb.png" border="0" alt="PowerShell Tutorial - Aliases" width="604" height="351" /></a><em></em></p>
<p><em>Listing PowerShell aliases</em></p>
<p>Notice in the above exhibit that when you type <strong>cls</strong> to clear the screen, PowerShell actually invokes the <strong>Clear-Host</strong> cmdlet. You can define your own aliases as well by using the<strong> Set-Alias </strong>cmdlet. The kernel idea here is that over time you can develop a completely tricked-out, personalized scripting environment that is tuned to your intuitive workflow and command preferences.</p>
<h2>Drives</h2>
<p>As I previously mentioned, Windows PowerShell is built atop the <a href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=2&amp;sqi=2&amp;ved=0CDYQFjAB&amp;url=http%3A%2F%2Fwww.microsoft.com%2Fnet%2F&amp;rct=j&amp;q=.net%20framework&amp;ei=zIb3TeGyGcydgQe9we33Cw&amp;usg=AFQjCNGomrrMGwdFwzEbF1eI5QsPtqik-w&amp;cad=rja">.NET Framework</a>. With PowerShell you can reach literally any aspect of local and/or remote computers, including the file system, the Registry, <a href="http://technet.microsoft.com/en-us/library/ee692772.aspx">Windows Management Instrumentation (WMI)</a> values, and the <a href="http://msdn.microsoft.com/en-us/library/aa746512%28v=vs.85%29.aspx">Active Directory Services Interface (ADSI)</a>.</p>
<p>According to Microsoft, a <a href="http://technet.microsoft.com/en-us/library/dd315335.aspx">Windows PowerShell drive</a> is a logical data store location that maps a logical name within PowerShell to a “real, live” data provider. Those data store locations can be:</p>
<ul>
<li>Local or remote filesystems</li>
<li>Digital certificates</li>
<li>Environment variables</li>
<li>Registry keys and/or values</li>
</ul>
<p>You can invoke the PowerShell cmdlet <strong>Get-PSDrive</strong> to obtain a list of currently loaded PowerShell drives on the local system. If you want to create a new PowerShell drive, then use the <strong>New-PSDrive</strong> cmdlet. The following exhibit demonstrates how we can define a virtual drive that maps to a remote file share.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/06/PowerShell.Tutorial.Drives.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/06/PowerShell.Tutorial.Drives.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="PowerShell Tutorial - Drives" src="http://4sysops.com/wp-content/uploads/2011/06/PowerShell.Tutorial.Drives_thumb.png" border="0" alt="PowerShell Tutorial - Drives" width="604" height="107" /></a></p>
<p><em>Figure 2: Defining a new PowerShell drive</em></p>
<p>In the preceding example, the alias remotedocs represents the <strong>\\srv1\documents</strong> remote file share. We can access the new PowerShell drive by using the command <strong>dir remotedocs</strong>.</p>
<h2>Conclusion</h2>
<p>At this point you should have a pretty good grasp of basic Windows PowerShell terminology. I will leave you with a laundry list of resources that I hope you will find helpful for further study in PowerShell. In the meantime, if there are other PowerShell-related topics that on which you would like to see coverage here at 4sysops, then please leave your request in the comments. Thanks! Next in this series you will learn how to run a PowerShell script.</p>
<p><strong><span style="text-decoration: underline;">For Further Study:</span></strong></p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Windows_PowerShell">Wikipedia article on Windows PowerShell</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/dd378937%28v=ws.10%29.aspx">Active Directory Administration with Windows PowerShell</a></li>
<li><a href="http://technet.microsoft.com/en-us/scriptcenter/dd742419">Scripting with Windows PowerShell</a></li>
<li><a href="http://thepowershellguy.com/blogs/posh/default.aspx">The PowerShell Guy</a></li>
<li><a href="http://huddledmasses.org/powershell-modules/">PowerShell Modules</a></li>
<li><a href="http://www.cbtnuggets.com/series/?id=456">CBT Nuggets Windows PowerShell Training</a></li>
<li><a href="http://www.techrepublic.com/blog/10things/10-powershell-commands-every-windows-admin-should-know/2052">10 PowerShell Commands Every Windows Admin Should Know</a></li>
</ul>
Author: Timothy Warner
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/powershell-tutorial-for-admins-part-2-aliases-and-drives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[PowerShell Tutorial]]></series:name>
	</item>
		<item>
		<title>PowerShell tutorial for admins &#8211; Part 1: cmdlets and pipeline</title>
		<link>http://4sysops.com/archives/powershell-tutorial-for-admins-part-1-cmdlets-and-pipeline/</link>
		<comments>http://4sysops.com/archives/powershell-tutorial-for-admins-part-1-cmdlets-and-pipeline/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 23:10:33 +0000</pubDate>
		<dc:creator>Timothy Warner</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">https://4sysops.com/?p=6241</guid>
		<description><![CDATA[In part 1 of this PowerShell tutorial for Windows admins you will learn about the cmdlet and pipeline concepts.]]></description>
			<content:encoded><![CDATA[<p><strong><i>In part 1 of this PowerShell tutorial for Windows admins you will learn about the cmdlet and pipeline concepts.</i></strong></p>
<p>Microsoft <a href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=2&amp;ved=0CDAQFjAB&amp;url=http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Flibrary%2Fbb978526.aspx&amp;rct=j&amp;q=windows%20powershell&amp;ei=xIX3TZOgNIit0AHIjPGgCw&amp;usg=AFQjCNEvIcgZxlDObkkS_7SVJv5EkLQnbg&amp;cad=rja">Windows PowerShell</a> was conceived as the next-generation replacement for the old and reliable <strong><a href="http://en.wikipedia.org/wiki/Command_Prompt">cmd.exe</a></strong> command shell environment. What’s especially cool about PowerShell is that it has a lot to offer both Windows systems administrators as well as .NET solution developers.</p>
<p>Trouble is, you have doubtless discovered that the <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b4720b00-9a66-430f-bd56-ec48bfca154f">PowerShell documentation</a>, whether published by Microsoft or a third party, rarely differentiates between these two very different audiences. Therefore, administrators get confused and frustrated while trying to wade through PowerShell developer terminology, and .NET developers get befuddled and angry while trying to comprehend PowerShell administrator nomenclature.</p>
<p>To that end, I thought in this piece that I would attempt to help at least those in the systems administrator camp by explaining in plain English the primary PowerShell vocabulary terms. Let’s get started, shall we?</p>
<h2>The cmdlet</h2>
<p>The <em><a href="http://technet.microsoft.com/en-us/scriptcenter/dd772285">cmdlet</a></em> (pronounced COMMAND-let) is the basic building block of Windows PowerShell. When you install PowerShell 2.0 on a Windows system, you receive by default the core library of PowerShell cmdlets. As you probably know, Microsoft has invested heavily in PowerShell technology. Therefore, most Microsoft server technologies ship with their own custom PowerShell modules. Examples of first-party extension modules include Active Directory, SQL Server 2008, SharePoint Server 2010 and Exchange Server 2010.</p>
<p>Regardless of their source, all cmdlets are designed (1) using a consistent usage rubric; and (2) to accomplish a single, specific task. Take a look at the following exhibit, and we’ll break down the constituent parts and pieces of a typical PowerShell command:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/06/PowerShell.Tutorial.cmdlet.Components.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/06/PowerShell.Tutorial.cmdlet.Components.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="PowerShell Tutorial - cmdlet Components" src="http://4sysops.com/wp-content/uploads/2011/06/PowerShell.Tutorial.cmdlet.Components_thumb.png" border="0" alt="PowerShell Tutorial - cmdlet Components" width="604" height="158" /></a><em></em></p>
<p><em>The PowerShell cmdlet and its components</em></p>
<p>Cmdlets always consist of a verb-noun compound phrase separated by a hyphen; this is done by design in order to make remembering PowerShell commands easy and intuitive. In the previous example, <strong>Get-ChildItem</strong>, the <strong>Get</strong> (verb) part of the command directs the action; in this case, to retrieve data. The <strong>ChildItem</strong> (noun) part of the command provides the focus for the verb; in the example, to obtain a directory listing.</p>
<p><em><strong>NOTE</strong>: Cmdlets are completely case IN-sensitive. Therefore, the statements <strong>get-childitem</strong>, <strong>Get-ChildItem</strong>, and <strong>GET-CHILDITEM</strong> are all equivalent in practice.</em></p>
<p>You will discover that PowerShell uses many of the same verbs regardless of the origin or context of a particular PowerShell cmdlet:</p>
<ul>
<li>Get</li>
<li>Set</li>
<li>Add</li>
<li>Remove</li>
<li>Clear</li>
<li>Enable</li>
<li>Disable</li>
<li>Start</li>
<li>Restart</li>
<li>Resume</li>
<li>Stop</li>
</ul>
<p>Please check out the nifty <a href="http://ss64.com/ps/">A-Z Index of Windows PowerShell 2.0 Commands</a> for an alphabetical list of the built-in Windows PowerShell v2.0 cmdlet library.</p>
<p>Most PowerShell cmdlets support one or more parameters and arguments. A <em>parameter</em> represents additional data that is passed into a cmdlet to customize its operation. In PowerShell nomenclature, a <em>named</em> <em>parameter</em> is the parameter name followed by an argument. While most named parameters are prepended with a hyphen (-), not all are.</p>
<p>Moreover, not all cmdlets require an argument to accompany a parameter; these are called <em>positional</em> parameters because all that is required is the name of the cmdlet and the name of the parameter issued the proper order.</p>
<p>You can instruct PowerShell to list the full syntax of any available cmdlet by typing <strong>get-help <em>cmdletname</em></strong> from the PowerShell prompt.</p>
<p>In case you haven’t picked this up from context, an <em>argument</em> is nothing more than a value that is passed to a parameter. In the current example, the <strong>Get-ChildItem</strong> cmdlet, which functions identically to the <a href="http://ss64.com/nt/">old DOS dir command</a>, requires that you pass an argument (namely, the <a href="http://en.wikipedia.org/wiki/Filespec">filespec</a> for which you need a directory listing) to the cmdlet. In this case, <strong>-path</strong> is a positional parameter and can safely be omitted; thus, the statements <strong>Get-ChildItem –path C:\Tools </strong>and <strong>Get-ChildItem C:\Tools</strong> are synonymous.</p>
<h2>The Pipeline</h2>
<p>One of the most powerful aspects of Windows PowerShell (besides the fact that its command set has its roots in the all-pervasive .NET Framework, that is), is what is called <a href="http://technet.microsoft.com/en-us/library/ee176927.aspx">the pipeline</a>. Those of you who are already masters of *NIX shell scripting are already familiar with the pipeline, but for us Windows administrators, give a listen.</p>
<p>In PowerShell, <em>piping</em> refers to the process of passing the results of one cmdlet as an argument into a second cmdlet. Therefore, the pipeline enables us to create compound cmdlet sequences that perform multiple tasks in a single operation. Take a look at the following example:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2011/06/PowerShell.tutorial.pipeline.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2011/06/PowerShell.tutorial.pipeline.png','',event,300,75)"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="PowerShell tutorial - pipeline" src="http://4sysops.com/wp-content/uploads/2011/06/PowerShell.tutorial.pipeline_thumb.png" border="0" alt="PowerShell tutorial - pipeline" width="604" height="351" /></a><em></em></p>
<p><em>The PowerShell pipeline</em></p>
<p>In the previous example, we “chain” together three PowerShell cmdlets by using the pipe (|) character. The net result in this case is that we receive a nifty, formatted list of our Windows services, organized by their run status. Pretty cool, eh?</p>
<h2>Conclusion</h2>
<p>There is <em>so much more</em> to Windows PowerShell for us systems administrators that I have had space or time to devote to in this brief article. In the second installment of this two-part miniseries, Windows PowerShell Terminology for Administrators: Part 2 of 2, I will cover two additional basic PowerShell terms: <a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-2-aliases-and-drives/"><em>Alias</em> and <em>PowerShell Drive</em></a>.</p>
<p>If there are other PowerShell-related topics that on which you would like to see coverage here at 4sysops, then please leave your request in the comments. Thanks!</p>
Author: Timothy Warner
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/powershell-tutorial-for-admins-part-1-cmdlets-and-pipeline/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<series:name><![CDATA[PowerShell Tutorial]]></series:name>
	</item>
		<item>
		<title>Poll results: GUI vs. CLI</title>
		<link>http://4sysops.com/archives/poll-results-gui-vs-cli/</link>
		<comments>http://4sysops.com/archives/poll-results-gui-vs-cli/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 19:33:12 +0000</pubDate>
		<dc:creator>Michael Pietroforte</dc:creator>
				<category><![CDATA[Poll]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/?p=3623</guid>
		<description><![CDATA[<p>More than 1,100 4sysops readers took part in this poll. I asked whether a graphical user interface (GUI) or a command line interface (CLI) was preferred when it comes to Windows administration. The results are quite clear: 66% prefer a GUI tool, 17% prefer the command line, and for another 17%, it doesn&#8217;t make a difference.</p>
<p>Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.</p>
<p>I suppose if I had asked this question a few years ago, we would have received an even stronger bias for the GUI. PowerShell is changing the view of many Windows admins, simply because you can now do many things on the CLI that you can&#8217;t do with the admin tools that come with Windows. Before we had PowerShell, the Windows command prompt was mostly used for relatively trivial tasks like pinging a remote computer or perhaps clearing the DNS cache.</p>
<p>It is not difficult &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>More than 1,100 4sysops readers took part in this poll. I asked whether a graphical user interface (GUI) or a command line interface (CLI) was preferred when it comes to Windows administration. The results are quite clear: 66% prefer a GUI tool, 17% prefer the command line, and for another 17%, it doesn&#8217;t make a difference.</p>
<p>Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.</p>
<p>I suppose if I had asked this question a few years ago, we would have received an even stronger bias for the GUI. PowerShell is changing the view of many Windows admins, simply because you can now do many things on the CLI that you can&#8217;t do with the admin tools that come with Windows. Before we had PowerShell, the Windows command prompt was mostly used for relatively trivial tasks like pinging a remote computer or perhaps clearing the DNS cache.</p>
<p>It is not difficult to guess for what I have voted. I am clearly pro GUI. It is not really that I am completely against working on command prompt. On a Linux server, I wouldn&#8217;t even install a desktop environment. In my view, Windows is just not made for the command line. Perhaps this is the reason why PowerShell commands are often so longwinded.</p>
<p>What upsets me in this discussion is the argument that you can &#8220;automate&#8221; administration tasks with PowerShell. In my opinion, this claim is absolutely meaningless. Every piece of software is meant to automate tasks. In fact, software has no other purpose. PowerShell fans usually want to imply with this assertion that with GUI tools, you have to do everything manually and that Windows admins can save a lot of time if they finally start automating things, just as their Linux colleagues do. The main reason why Windows is so successful is because there are so many great administration tools available that allow you to automate all kinds of tasks for thousands of machines with just a few clicks.</p>
<p>However, that doesn&#8217;t mean that I am against PowerShell. On the contrary! PowerShell is one of the most important Windows enhancements of the last years. It is probably the best programming language for Windows management. Thus, it has become a very important tool for all system management developers.</p>
<p>I also recommend that every Windows admin learns PowerShell. Microsoft sometimes offers only a PowerShell interface for new Windows features, probably in the hope that someone else will take on the expensive task of programming a graphical user interface. And, of course, sometimes you have no other choice than to write a script to get the job done, simply because no one else has yet written such a program or because your organization can&#8217;t afford a new tool. (Even though this is <a href="http://4sysops.com/archives/a-different-network-why-administrators-should-avoid-scripting/">not as often</a> the case as in former times.) Some readers have pointed out that it depends on the kind of task whether a GUI or a CLI is preferable. This is certainly also true.</p>
<p>The fact that one third of Windows admins can live perfectly with the command prompt also shows that, to a certain degree, the answer to this question is a matter of taste. Not all brains work the same way. I have seen admins who can type faster than I can think. If you feel comfortable on the command prompt, my anti-CLI rants won&#8217;t persuade you anyway. I am the most tolerant person when it comes to the choice of the right administration tool. Just do me the favor and don&#8217;t tell me that you can automate tasks just because you have PowerShell. It is like telling me that you can sit because you have the tools to build a chair and all others have to keep standing.</p>
Author: Michael Pietroforte
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/free-setacl-manage-access-control-lists-acl/" title="FREE: SetACL &#8211; Manage access control lists (acl) (September 5, 2011)">FREE: SetACL &#8211; Manage access control lists (acl)</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/poll-results-gui-vs-cli/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Active Directory management with PowerShell v2</title>
		<link>http://4sysops.com/archives/active-directory-management-with-powershell-v2/</link>
		<comments>http://4sysops.com/archives/active-directory-management-with-powershell-v2/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 17:26:52 +0000</pubDate>
		<dc:creator>Alexander Weiss</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/?p=3556</guid>
		<description><![CDATA[<p>The introduction of PowerShell was a major improvement for all administrators who are not afraid of the CLI. However, it also has some drawbacks. For instance, it is not included in the OS and it lacks many features. Microsoft wanted to correct those shortcomings. PowerShell Version 2 is now a part of Windows 7 and Windows Server 2008 RC2 and offers many new Cmdlets. One area that was improved is the management of the Active Directory (AD).</p>
<p>If you want to use these new features, you have to add the Cmdlets first. PowerShell v2 is now modularized. This only works under Windows Server, because you need to install the role “Active Directory Services” and the feature “Remote Server Administration Tools.” You can use the Server Manager for the installation, or if you prefer typing the following commands, you will have the same results:</p>
<p><em>import-module servermanager
Add-WindowsFeature -Name “RSAT-AD-PowerShell” -IncludeAllSubFeature
import-module ActiveDirectory</em></p>
<p>Now you have all the tools and are ready &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>The introduction of PowerShell was a major improvement for all administrators who are not afraid of the CLI. However, it also has some drawbacks. For instance, it is not included in the OS and it lacks many features. Microsoft wanted to correct those shortcomings. PowerShell Version 2 is now a part of Windows 7 and Windows Server 2008 RC2 and offers many new Cmdlets. One area that was improved is the management of the Active Directory (AD).</p>
<p>If you want to use these new features, you have to add the Cmdlets first. PowerShell v2 is now modularized. This only works under Windows Server, because you need to install the role “Active Directory Services” and the feature “Remote Server Administration Tools.” You can use the Server Manager for the installation, or if you prefer typing the following commands, you will have the same results:</p>
<p><em>import-module servermanager
Add-WindowsFeature -Name “RSAT-AD-PowerShell” -IncludeAllSubFeature
import-module ActiveDirectory</em></p>
<p>Now you have all the tools and are ready to check them out. One novation is that the AD gets mounted like a drive. The command to change to the drive and display its content is the same as with other drives:</p>
<p><em>cd AD:
dir</em></p>
<p>Your window should look like this now:</p>
<p><a href="http://4sysops.com/wp-content/uploads/2009/10/MountActiveDirectoryinPowerShell1.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2009/10/MountActiveDirectoryinPowerShell1.png','',event,300,75)"><img style="border-bottom: 0px; border-left: 0px; margin: 0px; display: inline; border-top: 0px; border-right: 0px" title="Mount-Active-Directory-in-PowerShell" src="http://4sysops.com/wp-content/uploads/2009/10/MountActiveDirectoryinPowerShell_thumb1.png" border="0" alt="Mount-Active-Directory-in-PowerShell" width="604" height="323" /></a></p>
<p>If the AD was not mounted, make sure the relevant port (TCP 9389) is not blocked by a firewall. Besides that, the target AD Server must have installed the role “Active Directory Web Services.” If the requirements are met, you can add the drive with the following command:</p>
<p><em>New-PSDrive -PSProvider ActiveDirectory -Name AD -Root “” -Server “server.domain.tld” -get-credential</em></p>
<p><a href="http://4sysops.com/wp-content/uploads/2009/10/ActiveDirectoryPowerShellCMDlets1.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2009/10/ActiveDirectoryPowerShellCMDlets1.png','',event,300,75)"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 4px; display: inline; border-top: 0px; border-right: 0px" title="Active-Directory-PowerShell-CMDlets" src="http://4sysops.com/wp-content/uploads/2009/10/ActiveDirectoryPowerShellCMDlets_thumb1.png" border="0" alt="Active-Directory-PowerShell-CMDlets" width="222" height="324" align="right" /></a> Here is a screenshot with an overview of all available Cmdlets:</p>
<p>The list was created with the following Cmdlet:</p>
<p><em>(Get-Module ActiveDirectory).ExportedCommands | format-table -Autosize</em></p>
<p>The help text for, e.g., the Get-ADForest Cmdlet, is displayed with this command:</p>
<p><em>get-help Get-ADForest</em></p>
<p>Now you can create and alter objects. I&#8217;ll just give you a few examples of adding a user, a group and a user to a group. The final example deletes the created user:</p>
<p><em>New-ADUser -Name “User” -SamAccountName “Username” -GivenName “Miller” -Surname “John” -DisplayName “John Miller” -Path &#8216;ou=Office,DC=domain,DC=tld&#8217; </em></p>
<p><em>New-ADGroup -Name “GroupToJoin” -SamAccountName groupToJoin -GroupCategory security   -GroupScope Global -DisplayName “GroupToJoin” -Path &#8216;ou=Office,DC=domain,DC=tld&#8217; -Description “John wants to join this group”</em></p>
<p><em>Add-ADGroupMember “GroupToJoin” “Username”</em></p>
<p><em>Remove ADUser -Identity “Username”</em></p>
<p>The Cmdlets used for managing the Active Directory were not the only feature that got a nice boost with PowerShell v2. The management of HyperV and Exchange via PowerShell was also greatly improved. If you are interested in these topics, let me know and I&#8217;ll write about them.</p>
Author: Alexander Weiss
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/raffle-blackbird-auditor-for-active-directory-real-time-active-directory-auditing/" title="Raffle: Blackbird Auditor for Active Directory &#8211; Real-time Active Directory auditing (May 23, 2012)">Raffle: Blackbird Auditor for Active Directory &#8211; Real-time Active Directory auditing</a> (0)</li>
	<li><a href="http://4sysops.com/archives/free-manageengine-free-active-directory-tools/" title="FREE: ManageEngine Free Active Directory Tools (May 18, 2012)">FREE: ManageEngine Free Active Directory Tools</a> (0)</li>
	<li><a href="http://4sysops.com/archives/microsoft-exam-70-640-operations-masters-sample-question/" title="Microsoft Exam 70-640 &#8211; Operations Masters &#8211; Sample question (April 9, 2012)">Microsoft Exam 70-640 &#8211; Operations Masters &#8211; Sample question</a> (3)</li>
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/microsoft-exam-70-640-the-global-catalog-sample-question/" title="Microsoft Exam 70-640 &#8211; The Global Catalog &#8211; Sample question (March 8, 2012)">Microsoft Exam 70-640 &#8211; The Global Catalog &#8211; Sample question</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/active-directory-management-with-powershell-v2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A different network &#8211; Why administrators should avoid scripting</title>
		<link>http://4sysops.com/archives/a-different-network-why-administrators-should-avoid-scripting/</link>
		<comments>http://4sysops.com/archives/a-different-network-why-administrators-should-avoid-scripting/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 19:54:20 +0000</pubDate>
		<dc:creator>Michael Pietroforte</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/?p=3150</guid>
		<description><![CDATA[<p>Coincidentally, shortly after I wrote the article for the <a href="http://4sysops.com/archives/poll-command-line-or-gui-administration-tools-what-do-you-prefer/">GUI vs. CLI</a> poll I came across a related topic. PowerShell did not only make the renaissance of the command line possible, the marketing buzz around it also tempts Windows administrators who never wrote a line of code before to program scripts to &#8220;automate&#8221; administration tasks. I would like to cite a paragraph from Robert B. Laughlin&#8217;s (winner of the Nobel Prize in Physics) book &#8220;<a href="http://www.amazon.com/Different-Universe-Reinventing-Physics-Bottom/dp/0465038298/ref=sr_1_1?ie=UTF8&#38;s=books&#38;qid=1246883663&#38;sr=8-1">A different Universe</a>&#8221; (p. 68) that I am currently reading. (I highly recommend this book to everyone who is interested in Physics and the Philosophy of Physics).</p>
<blockquote><p>One of the more interesting trends of the computer age is that physical science students are increasingly unwilling or unable to write computer code. I was very upset when I first observed this and took stern measures in my department to counteract it, much to the students&#8217; chagrin, for I myself am very good at coding and </p>&#8230;</blockquote>]]></description>
			<content:encoded><![CDATA[<p>Coincidentally, shortly after I wrote the article for the <a href="http://4sysops.com/archives/poll-command-line-or-gui-administration-tools-what-do-you-prefer/">GUI vs. CLI</a> poll I came across a related topic. PowerShell did not only make the renaissance of the command line possible, the marketing buzz around it also tempts Windows administrators who never wrote a line of code before to program scripts to &#8220;automate&#8221; administration tasks. I would like to cite a paragraph from Robert B. Laughlin&#8217;s (winner of the Nobel Prize in Physics) book &#8220;<a href="http://www.amazon.com/Different-Universe-Reinventing-Physics-Bottom/dp/0465038298/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1246883663&amp;sr=8-1">A different Universe</a>&#8221; (p. 68) that I am currently reading. (I highly recommend this book to everyone who is interested in Physics and the Philosophy of Physics).</p>
<blockquote><p>One of the more interesting trends of the computer age is that physical science students are increasingly unwilling or unable to write computer code. I was very upset when I first observed this and took stern measures in my department to counteract it, much to the students&#8217; chagrin, for I myself am very good at coding and consider it something any self-respecting technologist should know how to do. Eventually, however, I realized that the students were right and I was wrong, and stopped the crusade. Computer programming is one of those things in life, like fixing one&#8217;s own car, that is fascinating, fun, useful&#8211;and unacceptably time-consuming. The truth is that it is no longer cost-effective for most well-educated people to program their own computers, or even to learn how to do so. The wise use of a time is to spend a few bucks to buy a program that does what one wants, or in extreme cases, search the internet for free software.</p></blockquote>
<p>If you replace &#8220;physical science students&#8221; with &#8220;system administrators&#8221; you have more or less the same situation in today&#8217;s IT departments. Only most recently some administrators seem to be enticed by the powers of PowerShell to write their own code again.</p>
<p>I&#8217;ve often seen IT pros making the same mistake that Laughlin made at first. They believe that &#8220;any self-respecting IT pro should know how to code&#8221; and programming certainly also is &#8220;fascinating, fun, and useful&#8221;.</p>
<p>But as Laughlin correctly acknowledges, it is also &#8220;unacceptably time-consuming&#8221; and therefore, as far as IT departments are concerned, unacceptably expensive. The point here is that professional developers can do the job for a much lower price, especially if the program is not only used in one IT department , but in hundreds or thousands around the globe.</p>
<p>In the early days of networking, you simply had no other choice than to write your own scripts to get the job done. But those times are over. Rest assured that almost every &#8220;automation problem&#8221; you face has been already encountered by other admins somewhere else. And then, it is most likely that someone wrote a program to solve the problem which you can buy or perhaps even get <a href="http://4sysops.com/top-free-windows-administration-tools/">for free</a> on the web.</p>
<p>Thus, don&#8217;t make the mistake just because &#8220;PowerShell rocks&#8221; of wasting your time with coding if you could as well solve the problem in minutes with a downloadable tool. We live in a more and more specialized world. Programming and system administration were once just one discipline. But both fields have developed and are now highly complex; they are now two very distinct disciplines. To be successful you have no other choice than to focus on just one of them. Of course, if you are a developer working in an IT department, then PowerShell is now the first choice when it comes to programming Windows scripts.</p>
Author: Michael Pietroforte
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/a-different-network-why-administrators-should-avoid-scripting/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Poll: Command line or GUI administration tools? What do you prefer?</title>
		<link>http://4sysops.com/archives/poll-command-line-or-gui-administration-tools-what-do-you-prefer/</link>
		<comments>http://4sysops.com/archives/poll-command-line-or-gui-administration-tools-what-do-you-prefer/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 19:30:34 +0000</pubDate>
		<dc:creator>Michael Pietroforte</dc:creator>
				<category><![CDATA[Poll]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/?p=3148</guid>
		<description><![CDATA[<p>Recently, I stumbled upon a sentence in a Microsoft blog that made me wonder if there is a paradigmatic change happening in Redmond. Ned Pyle <a href="http://blogs.technet.com/askds/archive/2009/07/01/getting-over-replmon.aspx">discussed</a> the Windows Server 2003 adminpak tool <a href="http://technet.microsoft.com/en-us/library/cc772954%28WS.10%29.aspx">RepImon</a> (Active Directory Replication Monitor utility) as a replacement for the Windows Server 2008, <a href="http://technet.microsoft.com/en-us/library/cc755360%28WS.10%29.aspx">Repadmin</a> (Replication Diagnostics Tool). Both tools allow you to view the Active Directory replication status and to force synchronization between domain controllers. What is interesting here is that RepImon has a graphical user interface, whereas Repadmin is a command line tool.</p>
<p>To some extent, the article reads as if Repadmin is a new tool, yet both tools have already been introduced in Windows 2000. Therefore, Microsoft dropped a GUI tool in favor of the command line version. This is in contradiction to Microsoft’s official policy, i.e., that command line and graphical admin tools are supported in the same manner. It has occurred to me several times, however, that this is really no longer the &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Recently, I stumbled upon a sentence in a Microsoft blog that made me wonder if there is a paradigmatic change happening in Redmond. Ned Pyle <a href="http://blogs.technet.com/askds/archive/2009/07/01/getting-over-replmon.aspx">discussed</a> the Windows Server 2003 adminpak tool <a href="http://technet.microsoft.com/en-us/library/cc772954%28WS.10%29.aspx">RepImon</a> (Active Directory Replication Monitor utility) as a replacement for the Windows Server 2008, <a href="http://technet.microsoft.com/en-us/library/cc755360%28WS.10%29.aspx">Repadmin</a> (Replication Diagnostics Tool). Both tools allow you to view the Active Directory replication status and to force synchronization between domain controllers. What is interesting here is that RepImon has a graphical user interface, whereas Repadmin is a command line tool.</p>
<p>To some extent, the article reads as if Repadmin is a new tool, yet both tools have already been introduced in Windows 2000. Therefore, Microsoft dropped a GUI tool in favor of the command line version. This is in contradiction to Microsoft’s official policy, i.e., that command line and graphical admin tools are supported in the same manner. It has occurred to me several times, however, that this is really no longer the case. Ned Pyle indicates why:</p>
<blockquote><p>Windows administrators are much more comfortable with the command-line, and that’s great&#8230;</p></blockquote>
<p>I am not sure how to interpret this sentence. Perhaps he means that Windows admins are <em>now</em> more comfortable with the command line than they were some years ago, but the &#8220;that&#8217;s great&#8221; comment, as well as the tone in the article, seem to claim that Windows admins currently <em>prefer</em> command line tools.</p>
<p>This sort of praising of command line tools is relatively new for Microsoft, and it all started with the introduction of PowerShell. The idea for PowerShell was born at a time when many believed that Linux was a serious threat to Windows. Linux advocates often argued that Windows&#8217; MS-DOS-based command shell is no match for the UNIX-like shells of the Open Source OS. Microsoft then decided to make up for this shortcoming. It was with the release of PowerShell 2.0 that Microsoft actually surpassed Linux in this field.</p>
<p>This certainly strengthens the Windows platform, but I also see the danger in the possibility that Repadmin won&#8217;t be the last tool that will be dropped in favor of a command line tool. Of course, it is much cheaper to develop a command line tool than the corresponding GUI version. Since more and more Microsoft tools are now based on PowerShell, the temptation to offer only a command line version is significant.</p>
<p>In detail, I&#8217;ve already outlined my view about the <a href="http://4sysops.com/archives/why-powershell-servermanagercmd-and-co-don%E2%80%99t-really-rock-on-the-command-prompt/">GUI-CLI controversy</a>. I am still very much pro-GUI, and I believe that this renaissance of the command line interface (CLI) is a step backward. I started working as a sys admin at a time before Windows conquered PC networks, and I am also used to managing Linux boxes. In this respect, I feel like I know both worlds.</p>
<p>Anyway, I would like to know if Ned Pyle&#8217;s claim is true. I know that my obvious support for the GUI fraction endangers the validity of this poll since it might influence some readers. However, I also recommend reading Ned Pyle&#8217;s article as a counterweight. You might also want to read some of the <a href="http://4sysops.com/archives/why-powershell-servermanagercmd-and-co-don%E2%80%99t-really-rock-on-the-command-prompt/#comments">pro CLI comments</a> in my former rant against the CLI.</p>
<p>Before you vote, sit back for a moment, forget everything you have read, close your eyes, and then imagine your daily work as a Windows admin. Then, make your decision.</p>
<p>Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.</p>
Author: Michael Pietroforte
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/free-setacl-manage-access-control-lists-acl/" title="FREE: SetACL &#8211; Manage access control lists (acl) (September 5, 2011)">FREE: SetACL &#8211; Manage access control lists (acl)</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/poll-command-line-or-gui-administration-tools-what-do-you-prefer/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Windows PowerShell ISE &#8211; The better Command Prompt</title>
		<link>http://4sysops.com/archives/windows-powershell-ise-the-better-command-prompt/</link>
		<comments>http://4sysops.com/archives/windows-powershell-ise-the-better-command-prompt/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 01:02:59 +0000</pubDate>
		<dc:creator>Michael Pietroforte</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/?p=2434</guid>
		<description><![CDATA[<p><a href="http://4sysops.com/wp-content/uploads/2009/02/powershellise2.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2009/02/powershellise2.png','',event,300,75)"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 0px 4px; border-right-width: 0px" title="PowerShell-ISE2" src="http://4sysops.com/wp-content/uploads/2009/02/powershellise2-thumb.png" border="0" alt="PowerShell-ISE2" width="204" height="182" align="right" /></a> PowerShell ISE (Integrated Scripting Environment), formerly known as <a href="http://4sysops.com/archives/graphical-powershell-screenshots-of-microsofts-new-free-powershell-ide/">Graphical PowerShell</a>, is a graphical development environment and Command Prompt alternative. It is part of PowerShell 2.0, which has been integrated into Windows 7 and Windows Server 2008 R2, and is available as a <a href="http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=c913aeab-d7b4-4bb1-a958-ee6d7fe307bc&#38;displaylang=en">Community Technology Preview (CTP)</a> for Windows XP and Windows Vista.</p>
<p>I believe PowerShell’s integration into Windows will bring its breakthrough. As far as I’m concerned, the &#8220;DOS Command Prompt&#8221; is finally dead. Even if you haven’t found the time to learn PowerShell yet, it makes sense to use PowerShell ISE whenever you need a command line, because a graphical user interface is much more convenient.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2009/02/powershelliseshells.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2009/02/powershelliseshells.png','',event,300,75)"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px; border-right-width: 0px" title="PowerShell-ISE-Shells" src="http://4sysops.com/wp-content/uploads/2009/02/powershelliseshells-thumb.png" border="0" alt="PowerShell-ISE-Shells" width="204" height="177" align="right" /></a> The main advantage of PowerShell ISE is that you can work within two panes: one for typing commands and one where the output results are displayed. There is a third pane for editing scripts, but you can disable it, so as to have more space for the output pane.</p>
<p>My only complaint &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://4sysops.com/wp-content/uploads/2009/02/powershellise2.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2009/02/powershellise2.png','',event,300,75)"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 0px 4px; border-right-width: 0px" title="PowerShell-ISE2" src="http://4sysops.com/wp-content/uploads/2009/02/powershellise2-thumb.png" border="0" alt="PowerShell-ISE2" width="204" height="182" align="right" /></a> PowerShell ISE (Integrated Scripting Environment), formerly known as <a href="http://4sysops.com/archives/graphical-powershell-screenshots-of-microsofts-new-free-powershell-ide/">Graphical PowerShell</a>, is a graphical development environment and Command Prompt alternative. It is part of PowerShell 2.0, which has been integrated into Windows 7 and Windows Server 2008 R2, and is available as a <a href="http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=c913aeab-d7b4-4bb1-a958-ee6d7fe307bc&amp;displaylang=en">Community Technology Preview (CTP)</a> for Windows XP and Windows Vista.</p>
<p>I believe PowerShell’s integration into Windows will bring its breakthrough. As far as I’m concerned, the &#8220;DOS Command Prompt&#8221; is finally dead. Even if you haven’t found the time to learn PowerShell yet, it makes sense to use PowerShell ISE whenever you need a command line, because a graphical user interface is much more convenient.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2009/02/powershelliseshells.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2009/02/powershelliseshells.png','',event,300,75)"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px; border-right-width: 0px" title="PowerShell-ISE-Shells" src="http://4sysops.com/wp-content/uploads/2009/02/powershelliseshells-thumb.png" border="0" alt="PowerShell-ISE-Shells" width="204" height="177" align="right" /></a> The main advantage of PowerShell ISE is that you can work within two panes: one for typing commands and one where the output results are displayed. There is a third pane for editing scripts, but you can disable it, so as to have more space for the output pane.</p>
<p>My only complaint is that the command pane isn&#8217;t able to display a list of previously entered commands. You can navigate through commands with the cursor keys, as with the Command Prompt, but this is a very inconvenient way of accessing old commands, particularly if you have to accomplish complicated tasks that require many steps. If there was a complete list of all entered commands, you could just select the appropriate line without having to press the cursor key numerous times.</p>
<p>A good feature is the ability to resize PowerShell ISE&#8217;s, window using the mouse. I have never understood why the default width of the Command Prompt is only 80 characters, or why you can only resize it by accessing the window’s properties menu. Moreover, the Command Prompt&#8217;s copy and paste function is quite cumbersome. If a command or output overruns a line, it is impossible to highlight the whole line. Another nice feature of PowerShell ISE is that you can work with multiple shell tabs, which is more convenient than opening multiple Command Prompt windows.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2009/02/powershellisecommandpromptselect.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2009/02/powershellisecommandpromptselect.png','',event,300,75)"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px; border-right-width: 0px" title="PowerShell-ISE-command-prompt-select" src="http://4sysops.com/wp-content/uploads/2009/02/powershellisecommandpromptselect-thumb.png" border="0" alt="PowerShell-ISE-command-prompt-select" width="304" height="190" /></a> <a href="http://4sysops.com/wp-content/uploads/2009/02/powershelliseselect.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2009/02/powershelliseselect.png','',event,300,75)"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px; border-right-width: 0px" title="PowerShell-ISE-select" src="http://4sysops.com/wp-content/uploads/2009/02/powershelliseselect-thumb.png" border="0" alt="PowerShell-ISE-select" width="304" height="216" /></a></p>
<p>Of course, the main function of PowerShell ISE is that you can use it for PowerShell commands. Moreover, it is much more convenient to write scripts in PowerShell ISE than it is in Notepad, because of features such as syntax highlighting, script tabs, and basic debugging capabilities.</p>
<p>However, if you often write PowerShell programs you probably will prefer the free <a href="http://4sysops.com/archives/powergui-create-powershell-scripts-with-a-gui/">PowerGUI</a> tool, mostly because of its <a href="http://www.powergui.org/kbcategory.jspa?categoryID=21">PowerPacks</a>, which simplify the creation of PowerShell scripts for all kinds of products within the Windows ecosystem. Considering that PowerShell ISE can also be extended by third parties, I assume that there will be some interesting competition between the two in the future. This will also mean commercial products like <a href="http://www.idera.com/Content/Show65.aspx">Idera PowerShell Plus</a> might find it hard to keep up.</p>
Author: Michael Pietroforte
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/windows-powershell-ise-the-better-command-prompt/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>FREE: PowerGUI &#8211; Create PowerShell scripts with a GUI</title>
		<link>http://4sysops.com/archives/powergui-create-powershell-scripts-with-a-gui/</link>
		<comments>http://4sysops.com/archives/powergui-create-powershell-scripts-with-a-gui/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 20:35:16 +0000</pubDate>
		<dc:creator>Michael Pietroforte</dc:creator>
				<category><![CDATA[Free Tools]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/archives/powergui-create-powershell-scripts-with-a-gui/</guid>
		<description><![CDATA[<p><a href="http://4sysops.com/wp-content/uploads/2008/03/powergui-logo.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2008/03/powergui-logo.png','',event,300,75)"><img style="border-width: 0px" src="http://4sysops.com/wp-content/uploads/2008/03/powergui-logo-thumb.png" border="0" alt="PowerGUI_logo" width="244" height="174" align="left" /></a> PowerGUI is a free tool that allows you to create PowerShell scripts with a <strong>graphical user interface (GUI)</strong>. It also comes with a nice PowerShell <strong>script editor</strong> that supports <strong>debugging</strong>. Version 1 has been available for some days already.</p>
<p>The main idea behind PowerGUI is to <strong>create PowerShell code by selecting objects, and performing actions on them</strong>. For instance, you can select Active Directory objects or Exchange objects manually or by using filters. Then you tell PowerGUI that you want to move these objects to a new location and it will create the corresponding PowerShell script which you can enhance with your own code.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2008/03/powergui.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2008/03/powergui.png','',event,300,75)"><img style="border-width: 0px" src="http://4sysops.com/wp-content/uploads/2008/03/powergui-thumb.png" border="0" alt="PowerGUI" width="200" height="150" align="right" /></a> This can be helpful for<strong> PowerShell beginners</strong>. However, you should have some basic knowledge of PowerShell or at least some experiences in object oriented programming. The real power of PowerGUI is that it helps you <strong>find the objects and their attributes easily</strong>. If you ever wrote a program to manipulate objects &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://4sysops.com/wp-content/uploads/2008/03/powergui-logo.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2008/03/powergui-logo.png','',event,300,75)"><img style="border-width: 0px" src="http://4sysops.com/wp-content/uploads/2008/03/powergui-logo-thumb.png" border="0" alt="PowerGUI_logo" width="244" height="174" align="left" /></a> PowerGUI is a free tool that allows you to create PowerShell scripts with a <strong>graphical user interface (GUI)</strong>. It also comes with a nice PowerShell <strong>script editor</strong> that supports <strong>debugging</strong>. Version 1 has been available for some days already.</p>
<p>The main idea behind PowerGUI is to <strong>create PowerShell code by selecting objects, and performing actions on them</strong>. For instance, you can select Active Directory objects or Exchange objects manually or by using filters. Then you tell PowerGUI that you want to move these objects to a new location and it will create the corresponding PowerShell script which you can enhance with your own code.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2008/03/powergui.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2008/03/powergui.png','',event,300,75)"><img style="border-width: 0px" src="http://4sysops.com/wp-content/uploads/2008/03/powergui-thumb.png" border="0" alt="PowerGUI" width="200" height="150" align="right" /></a> This can be helpful for<strong> PowerShell beginners</strong>. However, you should have some basic knowledge of PowerShell or at least some experiences in object oriented programming. The real power of PowerGUI is that it helps you <strong>find the objects and their attributes easily</strong>. If you ever wrote a program to manipulate objects in a Microsoft application, then you know what I am talking about.</p>
<p><strong><a href="http://4sysops.com/wp-content/uploads/2008/03/powergui-script-editor.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2008/03/powergui-script-editor.png','',event,300,75)"><img style="border-width: 0px" src="http://4sysops.com/wp-content/uploads/2008/03/powergui-script-editor-thumb.png" border="0" alt="PowerGUI_Script_Editor" width="200" height="150" align="left" /></a> PowerGUIs script editor</strong> is great, too. It support syntax highlighting, autocomplete and offers bracket matching functionality. Most importantly, it comes with a nice debugger. I, personally, don’t like to write a script or program longer than five lines without a debugger at hand. The <a href="http://dmitrysotnikov.wordpress.com/2008/02/27/powergui-rtms/">latest version</a> supports pipeline debugging and breakpoints.</p>
<p>To get a quick overview of PowerGUI, I highly recommend watching this short <a href="http://powergui.org/shares/powergui/sbin/docs/PowerGUI_Introduction/PowerGUI_Introduction.html">online presentation</a>.</p>
<h2><a href="http://www.powergui.org/">PowerGUI</a></h2>
Author: Michael Pietroforte
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/powergui-create-powershell-scripts-with-a-gui/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Why PowerShell, Servermanagercmd and co. don’t really rock on the command prompt</title>
		<link>http://4sysops.com/archives/why-powershell-servermanagercmd-and-co-don%e2%80%99t-really-rock-on-the-command-prompt/</link>
		<comments>http://4sysops.com/archives/why-powershell-servermanagercmd-and-co-don%e2%80%99t-really-rock-on-the-command-prompt/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 21:29:26 +0000</pubDate>
		<dc:creator>Michael Pietroforte</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/archives/why-powershell-servermanagercmd-and-co-don%e2%80%99t-really-rock-on-the-command-prompt/</guid>
		<description><![CDATA[<p>Aaron has a nice post about the <a href="http://blog.stealthpuppy.com/windows/server-managers-power-is-in-the-command-line">command line interface of Server Manager</a> in Windows Server 2008. I have been blogging about <a href="http://4sysops.com/archives/windows-server-2008-server-roles-and-server-manager/">the graphical interface of Server Manager</a> a while back. I somehow forgot to mention that <strong>Server Manager has a command line version</strong>. So I am taking this chance to make up for my omission, although the main intent of this post is to express <strong>my view about the value of these new command line capabilities</strong> of Vista and Server 2008 in general.</p>
<p>The fact that I forgot to mention it is typical for me because <strong>I am not really a friend of the Windows command prompt</strong>. On Linux, it is just the opposite. I usually don&#8217;t even install KDE or Gnome on a Linux box. But from my point of view, Windows is just not made for this kind of administration. That&#8217;s why it is called Windows and not ComanndOS.</p>
<p>However this doesn&#8217;t mean that <strong>Server </strong>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Aaron has a nice post about the <a href="http://blog.stealthpuppy.com/windows/server-managers-power-is-in-the-command-line">command line interface of Server Manager</a> in Windows Server 2008. I have been blogging about <a href="http://4sysops.com/archives/windows-server-2008-server-roles-and-server-manager/">the graphical interface of Server Manager</a> a while back. I somehow forgot to mention that <strong>Server Manager has a command line version</strong>. So I am taking this chance to make up for my omission, although the main intent of this post is to express <strong>my view about the value of these new command line capabilities</strong> of Vista and Server 2008 in general.</p>
<p>The fact that I forgot to mention it is typical for me because <strong>I am not really a friend of the Windows command prompt</strong>. On Linux, it is just the opposite. I usually don&#8217;t even install KDE or Gnome on a Linux box. But from my point of view, Windows is just not made for this kind of administration. That&#8217;s why it is called Windows and not ComanndOS.</p>
<p>However this doesn&#8217;t mean that <strong>Server Manager&#8217;s command line capabilities</strong> don&#8217;t make sense at all. Actually, they can be very useful under certain circumstances. Usually, they come into play when you have to perform a certain task on many servers. But then you wouldn&#8217;t really use these commands on a prompt. Instead you would <strong>write a little script</strong> that does the job for you.</p>
<p>Usually, when I write such a script, I would try things first on the command prompt in a test environment. This is why such command line extensions of graphical tools can be quite useful. Scripting with Microsoft applications was always possible via APIs. The difference then is that you usually can&#8217;t <strong>just run a quick test on a command prompt</strong> if you write a program this way.</p>
<p>The same applies to <strong>PowerShell</strong>. The real power of PowerShell is that you can play with the commands while you write a little application. However, when things get a bit more complicated I prefer writing a real program with Visual Studio. So PowerShell like SERVERMANAGERCMD scripts are good for relatively simple automation tasks.</p>
<p>I know, there are many admins who disagree with me here, especially those who grew up in a <strong>UNIX environment </strong>will feel more at home on the command line. So to a certain degree, it is just a matter of taste if you work on the command prompt or with a GUI. However, <strong>I claim that under Windows in most cases you are simply faster with a graphical tool.
</strong></p>
<p>Takes one of <strong>Aaron&#8217;s examples</strong>:</p>
<p><code>SERVERMANAGERCMD -install TS-Terminal-Server,TS-Licensing,TS-Session-Broker -restart</code></p>
<p>I am not only referring to the fact that commands under Windows and also PowerShell tend to be quite <strong>long winded </strong>and will just cause finger arthritis in the long run. My point rather is that <strong>nobody memorizes such a command</strong> for a longer time. If you have to perform the same task after a month or so, you will start wondering if it was &#8220;TS-Session-Broker&#8221;, or was it just &#8220;session broker&#8221;? or maybe &#8220;TS-Sessionbroker&#8221;?</p>
<p>If you are an adventurous admin, you might just try and correct your command afterwards. But usually, you end up <strong>checking the manual</strong>. Then, you edit your command again, only to find out that Server Manager didn&#8217;t really do what you wanted because there was a <strong>typo in your command</strong>. If you are lucky, Windows would just respond with an error message. If this isn&#8217;t just your day, you would have seriously <strong>damaged some hundred servers</strong>.</p>
<p>One argument often put forward is <strong>that you can do more on the command prompt</strong> than with a GUI. This might be true in some rare cases, but <strong>can hardly be the reason for working always on the command prompt</strong>. And in some environments the opposite is true. For instance, you can&#8217;t configure server roles with Servermanagercmd.</p>
<p>It is also a big misunderstanding that you have somehow a <strong>more technical knowledge of the underlying processes</strong> if you work on the command prompt. Whether you understand what you are doing or not doesn&#8217;t depend on your typing skills, but on <strong>the time you invested to learn about the technical structure</strong> of your environment. Pasting a command from a manual and changing some of its parameters doesn&#8217;t really require geek knowledge.</p>
<p>That said, I certainly <strong>welcome the new command prompt capabilities</strong> of Vista and Server 2008. They are very useful in automating tasks in cases where the corresponding graphical tool doesn&#8217;t offer (yet) this functionality.</p>
<p>But, then, we usually talk about <strong>scripting</strong> and not about working on the command prompt. If you need a script for a certain task, it usually means that the developers of an application still have work to do to extend the graphical capabilities of their program. <strong>Scripting is nothing else than doing the job for your software vendor.</strong> Good graphical tools already come with all the automation you need. After all, every kind of program is only about automation. That&#8217;s why computers are so useful.</p>
<p>Thus, if someone from Microsoft tells you that <strong><a href="http://blogs.iis.net/bills/archive/2006/11/14/powershell-rocks.aspx">PowerShell really rocks</a> because you can automate</strong> all kinds of tasks with it, you can just respond that this is the <strong>very idea of any programming language</strong>. So I hope that in the future, Microsoft will add a feature to Server Manager that allows you to install server roles on multiple servers with just a mouse click.</p>
<p>The achievement of Windows and other graphic-oriented operating systems is that they made working with computers <strong>more human</strong>. Graphical interfaces mean more work for computers, but less for humans. Going back to the good old times of MS DOS is certainly not an option.</p>
<p><strong>How about you?</strong> Are you working often now on the command prompt because of these new command tools? Or are you just using them to write scripts and continue your daily work like before with graphical tools?</p>
Author: Michael Pietroforte
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/why-powershell-servermanagercmd-and-co-don%e2%80%99t-really-rock-on-the-command-prompt/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>FREE: GPMC PowerShell Cmdlets</title>
		<link>http://4sysops.com/archives/gpmc-powershell-cmdlets/</link>
		<comments>http://4sysops.com/archives/gpmc-powershell-cmdlets/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 21:10:10 +0000</pubDate>
		<dc:creator>External author</dc:creator>
				<category><![CDATA[Free Tools]]></category>
		<category><![CDATA[group policy]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/archives/gpmc-powershell-cmdlets/</guid>
		<description><![CDATA[<p><em>Submitted by Darren Mar-Elia</em><em> &#8211; Blog: <a href="http://www.sdmsoftware.com/blog">The GPOGuy Group Policy Blog</a>
</em>
The GPMC PowerShell cmdlets are a set of free cmdlets that wrap the functionality of Microsoft&#8217;s Group Policy Management Console (GPMC). The cmdlets provides functionality to PowerShell such as creating and deleting GPOs, linking and unlinking GPOs and modifying GPO permissions, to name just a few.</p>
<h2><a href="http://www.sdmsoftware.com/freeware.php">GPMC PowerShell Cmdlets</a></h2>
Author: External author
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/folder-redirection-part-5-best-practices/" title="Folder Redirection &#8211; Part 5: Best practices (May 14, 2012)">Folder Redirection &#8211; Part 5: Best practices</a> (1)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-4-group-policy-configuration/" title="Folder Redirection &#8211; Part 4: Group Policy configuration (May 9, 2012)">Folder Redirection &#8211; Part 4: Group Policy configuration</a> (0)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-3-explanation-of-folder-permissions/" title="Folder Redirection &#8211; Part 3: Explanation of folder permissions (May 7, 2012)">Folder Redirection &#8211; Part 3: Explanation of folder permissions</a> (4)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-2-setting-up-your-file-server/" title="Folder Redirection &#8211; Part 2: Setting up your file server (May 2, 2012)">Folder Redirection &#8211; Part 2: Setting up your file server</a> (0)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-1-introduction/" title="Folder Redirection &#8211; Part 1: Introduction (April 30, 2012)">Folder Redirection &#8211; Part 1: Introduction</a> (0)</li>
&#8230;</ul>]]></description>
			<content:encoded><![CDATA[<p><em>Submitted by Darren Mar-Elia</em><em> &#8211; Blog: <a href="http://www.sdmsoftware.com/blog">The GPOGuy Group Policy Blog</a>
</em>
The GPMC PowerShell cmdlets are a set of free cmdlets that wrap the functionality of Microsoft&#8217;s Group Policy Management Console (GPMC). The cmdlets provides functionality to PowerShell such as creating and deleting GPOs, linking and unlinking GPOs and modifying GPO permissions, to name just a few.</p>
<h2><a href="http://www.sdmsoftware.com/freeware.php">GPMC PowerShell Cmdlets</a></h2>
Author: External author
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/folder-redirection-part-5-best-practices/" title="Folder Redirection &#8211; Part 5: Best practices (May 14, 2012)">Folder Redirection &#8211; Part 5: Best practices</a> (1)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-4-group-policy-configuration/" title="Folder Redirection &#8211; Part 4: Group Policy configuration (May 9, 2012)">Folder Redirection &#8211; Part 4: Group Policy configuration</a> (0)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-3-explanation-of-folder-permissions/" title="Folder Redirection &#8211; Part 3: Explanation of folder permissions (May 7, 2012)">Folder Redirection &#8211; Part 3: Explanation of folder permissions</a> (4)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-2-setting-up-your-file-server/" title="Folder Redirection &#8211; Part 2: Setting up your file server (May 2, 2012)">Folder Redirection &#8211; Part 2: Setting up your file server</a> (0)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-1-introduction/" title="Folder Redirection &#8211; Part 1: Introduction (April 30, 2012)">Folder Redirection &#8211; Part 1: Introduction</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/gpmc-powershell-cmdlets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FREE: Specops Command &#8211; PowerShell meets Group Policy</title>
		<link>http://4sysops.com/archives/specops-command-powershell-meets-group-policy/</link>
		<comments>http://4sysops.com/archives/specops-command-powershell-meets-group-policy/#comments</comments>
		<pubDate>Fri, 04 Jan 2008 18:20:46 +0000</pubDate>
		<dc:creator>Michael Pietroforte</dc:creator>
				<category><![CDATA[Free Tools]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[group policy]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/archives/specops-command-powershell-meets-group-policy/</guid>
		<description><![CDATA[<p>Group Policy and PowerShell are both very powerful tools to automate IT management tasks. Specops Command combines both technologies giving you an even more powerful scripting solution.</p>
<p><a title="Specops Command Overview" href="http://4sysops.com/wp-content/uploads/2008/01/specopscommandoverview2.jpg" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2008/01/specopscommandoverview2.jpg','Specops Command Overview',event,300,75)"><img src="http://4sysops.com/wp-content/uploads/2008/01/specopscommandoverview2.jpg" alt="Specops Command Overview" /></a></p>
<p>There is a free and a commercial version. Please, check out this <a href="http://www.specopssoft.com/wiki/index.php/SpecopsCommand/Licensing">comparison table</a> for the differences between the two. These are the most interesting features of the free edition of Specops Command:</p>
<p><strong>Automatic PowerShell installation:</strong> The biggest problem you face when it comes to using PowerShell network wide is to get it installed on all your machines. Specops Command helps you deploy PowerShell in the background by using Group Policy software installation. It thereby makes sure that the correct PowerShell package is installed on different Windows editions.</p>
<p><strong>Foreground and background script execution using Group Policy:</strong> Specops Commands allows you to execute PowerShell scripts using well known Group Policy procedures. That is, you can remotely launch scripts in the foreground (boot or logon) or background (Group Policy refresh intervals).</p>
<p><strong>Credential elevation for user </strong>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Group Policy and PowerShell are both very powerful tools to automate IT management tasks. Specops Command combines both technologies giving you an even more powerful scripting solution.</p>
<p><a title="Specops Command Overview" href="http://4sysops.com/wp-content/uploads/2008/01/specopscommandoverview2.jpg" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2008/01/specopscommandoverview2.jpg','Specops Command Overview',event,300,75)"><img src="http://4sysops.com/wp-content/uploads/2008/01/specopscommandoverview2.jpg" alt="Specops Command Overview" /></a></p>
<p>There is a free and a commercial version. Please, check out this <a href="http://www.specopssoft.com/wiki/index.php/SpecopsCommand/Licensing">comparison table</a> for the differences between the two. These are the most interesting features of the free edition of Specops Command:</p>
<p><strong>Automatic PowerShell installation:</strong> The biggest problem you face when it comes to using PowerShell network wide is to get it installed on all your machines. Specops Command helps you deploy PowerShell in the background by using Group Policy software installation. It thereby makes sure that the correct PowerShell package is installed on different Windows editions.</p>
<p><strong>Foreground and background script execution using Group Policy:</strong> Specops Commands allows you to execute PowerShell scripts using well known Group Policy procedures. That is, you can remotely launch scripts in the foreground (boot or logon) or background (Group Policy refresh intervals).</p>
<p><strong>Credential elevation for user scripts:</strong> Users usually (hopefully) don&#8217;t have enough privileges for management tasks on their machines. Therefore, logon scripts often have to run with elevated credentials.</p>
<p><a title="Specops Command" href="http://4sysops.com/wp-content/uploads/2008/01/specops_command.png" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2008/01/specops_command.png','Specops Command',event,300,75)"><img src="http://4sysops.com/wp-content/uploads/2008/01/specops_command.thumbnail.png" alt="Specops Command" width="135" height="70" align="left" /></a>If you want to try Specops Command you should reserve some time for your test. The installation package installs the full version which is quite a sophisticated tool. The trial license allows you to use the full version for a limited time period. After that, you can continue using its free version. This <a href="http://www.specopssoft.com/powershell/specopscommand-sdm.wmv">video </a>will you give a first impression of how to use Specops Command.</p>
<h2><a href="http://www.specopssoft.com/powershell/">Specops Command</a></h2>
Author: Michael Pietroforte
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/raffle-blackbird-auditor-for-active-directory-real-time-active-directory-auditing/" title="Raffle: Blackbird Auditor for Active Directory &#8211; Real-time Active Directory auditing (May 23, 2012)">Raffle: Blackbird Auditor for Active Directory &#8211; Real-time Active Directory auditing</a> (0)</li>
	<li><a href="http://4sysops.com/archives/free-manageengine-free-active-directory-tools/" title="FREE: ManageEngine Free Active Directory Tools (May 18, 2012)">FREE: ManageEngine Free Active Directory Tools</a> (0)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-5-best-practices/" title="Folder Redirection &#8211; Part 5: Best practices (May 14, 2012)">Folder Redirection &#8211; Part 5: Best practices</a> (1)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-4-group-policy-configuration/" title="Folder Redirection &#8211; Part 4: Group Policy configuration (May 9, 2012)">Folder Redirection &#8211; Part 4: Group Policy configuration</a> (0)</li>
	<li><a href="http://4sysops.com/archives/folder-redirection-part-3-explanation-of-folder-permissions/" title="Folder Redirection &#8211; Part 3: Explanation of folder permissions (May 7, 2012)">Folder Redirection &#8211; Part 3: Explanation of folder permissions</a> (4)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/specops-command-powershell-meets-group-policy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://www.specopssoft.com/powershell/specopscommand-sdm.wmv" length="4719400" type="video/x-ms-wmv" />
		</item>
		<item>
		<title>Graphical PowerShell &#8211; Screenshots of Microsoft&#8217;s new free PowerShell IDE</title>
		<link>http://4sysops.com/archives/graphical-powershell-screenshots-of-microsofts-new-free-powershell-ide/</link>
		<comments>http://4sysops.com/archives/graphical-powershell-screenshots-of-microsofts-new-free-powershell-ide/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 20:12:46 +0000</pubDate>
		<dc:creator>Michael Pietroforte</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://4sysops.com/archives/graphical-powershell-screenshots-of-microsofts-new-free-powershell-ide/</guid>
		<description><![CDATA[<p>Yesterday, I blogged about my favorite four <a href="http://4sysops.com/archives/download-windows-powershell-20-ctp-my-favorite-new-features/">new PowerShell 2.0 features</a>. The one I like most is <strong>Graphical PowerShell</strong>. Maybe &#8220;<strong>IDE</strong>&#8221; (Integrated Development Environment) is an exaggeration. Graphical PowerShell is still a very <strong>simple tool</strong>. But, I think, it is a good start, and I hope that Microsoft will keep on adding new features. In this post, you&#8217;ll find some <strong>screenshots</strong> and a short description of Graphical PowerShell.</p>
<p>The first thing you should do before you start playing with Graphical PowerShell is to change the <strong>execution policy</strong> to &#8220;<strong>unrestricted</strong>&#8220;. Otherwise, you won&#8217;t be able to run scripts within Graphical PowerShell.  Open a PowerShell prompt as administrator and type:</p>
<p><code>Set-ExecutionPolicy Unrestricted</code></p>
<p>If you want to learn more about execution policies type:</p>
<p><code>get-help about_signing</code></p>
<p>Okay, let&#8217;s start looking at Graphical PowerShell.</p>
<h2>Syntax highlighting</h2>
<p>Check out the screenshot and you&#8217;ll see how Graphical PowerShell highlights syntax.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_syntax_highlighting.png" title="Graphical PowerShell Syntax Highlighting" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_syntax_highlighting.png','Graphical PowerShell Syntax Highlighting',event,300,75)"><img src="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_syntax_highlighting.thumbnail.png" alt="Graphical PowerShell Syntax Highlighting" /></a></p>
<h2>Multi-tabbed scripting pane</h2>
<p>Grapical PowerShell allows you to open multiple &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I blogged about my favorite four <a href="http://4sysops.com/archives/download-windows-powershell-20-ctp-my-favorite-new-features/">new PowerShell 2.0 features</a>. The one I like most is <strong>Graphical PowerShell</strong>. Maybe &#8220;<strong>IDE</strong>&#8221; (Integrated Development Environment) is an exaggeration. Graphical PowerShell is still a very <strong>simple tool</strong>. But, I think, it is a good start, and I hope that Microsoft will keep on adding new features. In this post, you&#8217;ll find some <strong>screenshots</strong> and a short description of Graphical PowerShell.</p>
<p>The first thing you should do before you start playing with Graphical PowerShell is to change the <strong>execution policy</strong> to &#8220;<strong>unrestricted</strong>&#8220;. Otherwise, you won&#8217;t be able to run scripts within Graphical PowerShell.  Open a PowerShell prompt as administrator and type:</p>
<p><code>Set-ExecutionPolicy Unrestricted</code></p>
<p>If you want to learn more about execution policies type:</p>
<p><code>get-help about_signing</code></p>
<p>Okay, let&#8217;s start looking at Graphical PowerShell.</p>
<h2>Syntax highlighting</h2>
<p>Check out the screenshot and you&#8217;ll see how Graphical PowerShell highlights syntax.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_syntax_highlighting.png" title="Graphical PowerShell Syntax Highlighting" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_syntax_highlighting.png','Graphical PowerShell Syntax Highlighting',event,300,75)"><img src="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_syntax_highlighting.thumbnail.png" alt="Graphical PowerShell Syntax Highlighting" /></a></p>
<h2>Multi-tabbed scripting pane</h2>
<p>Grapical PowerShell allows you to open multiple scripts and you can switch between them using tabs.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_tabs.png" title="Graphical PowerShell Tabs" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_tabs.png','Graphical PowerShell Tabs',event,300,75)"><img src="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_tabs.thumbnail.png" alt="Graphical PowerShell Tabs" /></a></p>
<h2>Run scripts</h2>
<p>In the upper pane, you can edit the scripts. After you saved it in a file, you can run it within Graphical PowerShell. The output of the script will be displayed in the middle pane.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_run.png" title="PowerShell Run Scripts" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_run.png','PowerShell Run Scripts',event,300,75)"><img src="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_run.thumbnail.png" alt="PowerShell Run Scripts" /></a></p>
<h2>Work on the command line</h2>
<p>To work interactively with PowerShell you have to type in commands in the lower pane. The ouput will be displayed in the middle pane.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_command_line.png" title="Graphical PowerShell Command Line" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_command_line.png','Graphical PowerShell Command Line',event,300,75)"><img src="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_command_line.thumbnail.png" alt="Graphical PowerShell Command Line" /></a></p>
<h2>Multiple runspaces</h2>
<p>The concept of <a href="http://msdn2.microsoft.com/en-us/library/ms714459.aspx">runspaces</a> is probably something for advanced PowerShell programmers. In Grapical PowerShell, you can consider them as different shells. Runspaces are organized in vertical tabs.</p>
<p><a href="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_runspace.png" title="Graphical PowerShell Runspaces" onclick="return enlarge('http://4sysops.com/wp-content/plugins/zap_imgpop/','http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_runspace.png','Graphical PowerShell Runspaces',event,300,75)"><img src="http://4sysops.com/wp-content/uploads/2007/11/graphical_powershell_runspace.thumbnail.png" alt="Graphical PowerShell Runspaces" /></a></p>
Author: Michael Pietroforte
<br />
<small>Copyright &#169; 2006-2012, 4sysops, Digital fingerprint: 3db371642e7c3f4fe3ee9d5cf7666eb0</small><br />
	<br /><strong>Related</strong>
	<ul class="st-related-posts">
	<li><a href="http://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/" title="Query free disk space details of remote computers using PowerShell (March 9, 2012)">Query free disk space details of remote computers using PowerShell</a> (3)</li>
	<li><a href="http://4sysops.com/archives/change-the-local-administrator-password-on-multiple-computers-with-powershell/" title="Change the local administrator password on multiple computers with PowerShell (January 13, 2012)">Change the local administrator password on multiple computers with PowerShell</a> (4)</li>
	<li><a href="http://4sysops.com/archives/query-and-kill-a-process-on-a-remote-computer-using-powershell-and-wmi/" title="Query and kill a process on a remote computer using PowerShell and WMI (December 9, 2011)">Query and kill a process on a remote computer using PowerShell and WMI</a> (0)</li>
	<li><a href="http://4sysops.com/archives/vbscript-vs-powershell/" title="VBScript vs. PowerShell (September 20, 2011)">VBScript vs. PowerShell</a> (0)</li>
	<li><a href="http://4sysops.com/archives/powershell-tutorial-for-admins-part-6-managing-server-roles-and-features/" title="PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features (July 14, 2011)">PowerShell tutorial for admins &#8211; Part 6: Managing server roles and features</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://4sysops.com/archives/graphical-powershell-screenshots-of-microsofts-new-free-powershell-ide/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

