This video provides an introduction to PowerShell, how to use it and the advantages of PowerShell over the Command Line. PowerShell is a replacement for the command prompt and thus the future. There are a lot more features in PowerShell than the command prompt, meaning better results can be achieved once you learn how to use it.
Command Prompt vs PowerShellThe command prompt was developed from the MS Dos prompt first released in the early 80’s. For this reason, it was based on the technology at the time and thus is limited in what it can achieve on modern hardware and operating systems. The command prompt processes commands one after the other which is often referred to as batch processing. PowerShell in comparison is task based. PowerShell can integrate with other technologies like .Net and can be interfaced directly like a programming language. The command prompt is not able to do this.
CmdLets
A CmdLet pronounced as a “command let” performs a single action. CmdLets follow the format verb noun. The verb indicates what action the CmdLet will perform, e.g. “set” would set a value. The noun indicates what the CmdLet will operate on. For example, by just looking at the CmdLet “Get-Random” name alone, you would know that is gets a random number.
Commands used in demonstration
CD
Write-Host “Hello World”
echo “Hello World”
Alias echo
Dir
alias dir
$DHCP=Get-Service DHCP
$DHCP.status
$DHCP.CanShutDown
$objOU=[ADSI]”LDAP://OU=New York,DC=ITFreeTraining,DC=local”
$objUser=$objOU.Create(“user”,”CN=Charlie Wilson”)
$objUser.Put(“sAMAccountName”,”Charlie.Wilson”)
$objUser.SetInfo()
$objUser=[ADSI]”LDAP://CN=John Doe,OU=Users,OU=New York,DC=ITFreeTraining.local,DC=local”
$objUser=[ADSI]”LDAP://CN=John Doe,OU=Users,OU=New York,DC=ITFreeTraining,DC=local”
$objUser.put(“GivenName”, “John”)
$objUser.put(“Initials”, “M”)
$objUser.put(“sn”, “Doe”)
$objUser.put(“DisplayName”, “John Doe”)
$objUser.put(“Description”, “Accounts”)
$objUser.put(“TelephoneNumber”, “555-555-5555″)
$objUser.put(“Mail”, “John.Doe@ITFreeTraining.com”)
$objUser.setInfo()
References
AuditPC.vbs http://itfreetraining.com/handouts/70-640/part2/auditpc.vbs
CreateUser.vbs http://itfreetraining.com/handouts/70-640/part2/createuser.vbs
“MCTS 70-640 Configuring Windows Server 2008 Active Directory” pg 98-108
“Windows PowerShell” http://en.wikipedia.org/wiki/Windows_PowerShell
Credits