Windows PowerShell for Beginners
BuckyBalls
Building Blocks
Common Engineering Criteria
70+ active internal partners
Lync Server • SharePoint Server • Service Manager • Windows Small
Business Server • Exchange Server • Windows Diagnostics • Server
Manager • SQL Server • Active Directory • Failover Clustering •
System Center Operations Manager • Windows Backup • Server
Migration • System Center Virtual Machine Manager • Best Practices
Analyzer • Active Directory Rights Management Services • Internet
Information Services • Background Intelligent Transfer Service •
System Center Data Protection Manager • Network Load Balancing •
Remote Desktop Services • Group Policy • WS-Management •
AppLocker • WMI
Agenda
Introduce Windows PowerShell
PowerShell Overview
Help Overview
Q&A!
Have some FUN!
What Is PowerShell?
Command line and scripting language
As interactive and composable as BASH/KSH
As programmatic as Perl/Python/Ruby
As production oriented as AS400 CL/VMS DCL
What Is PowerShell?
Windows PowerShell™ includes an interactive prompt and
a scripting environment
Commands are object-based
Large set of built-in commands
All shell commands use the same parser
Windows PowerShell 2.0 is installed by default on
Windows Server® 2008 R2 and Windows® 7
Productivity
Exchange 2003 (VBScript) Exchange 2007
(PowerShell)
Mailbo Set listExchange_Mailboxs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\COMPUTERNAME\ROOT\
MicrosoftExchangeV2").InstancesOf("Exchange_Mailbox") get-mailboxstatistics
x Stats For Each objExchange_Mailbox in listExchange_Mailboxs –server $servername
WScript.echo "AssocContentCount =” + objExchange_Mailbox.AssocContentCount
WScript.echo " DateDiscoveredAbsentInDS =” + objExchange_Mailbox.DateDiscoveredAbsentInDS
WScript.echo " DeletedMessageSizeExtended =” + objExchange_Mailbox. DeletedMessageSizeExtended
WScript.echo " LastLoggedOnUserAccount =” + objExchange_Mailbox. LastLoggedOnUserAccount
WScript.echo " LastLogoffTime =” + objExchange_Mailbox. LastLogoffTime
WScript.echo " LastLogonTime =” + objExchange_Mailbox. LastLogonTime
WScript.echo " LegacyDN =” + objExchange_Mailbox. LegacyDN
WScript.echo " MailboxDisplayName =” + objExchange_Mailbox. MailboxDisplayName
WScript.echo " MailboxGUID =” + objExchange_Mailbox. MailboxGUID
WScript.echo " ServerName =” + objExchange_Mailbox. ServerName
WScript.echo " Size =” + objExchange_Mailbox. Size
WScript.echo " StorageGroupName =” + objExchange_Mailbox. StorageGroupName
WScript.echo " StorageLimitInfo =” + objExchange_Mailbox. StorageLimitInfo
WScript.echo " StoreName =” + objExchange_Mailbox. StoreName
WScript.echo " TotalItems =” + objExchange_Mailbox. TotalItems
Next
Databa Dim StorGroup as New CDOEXM.StorageGroup
move-storagegrouppath
se StorGroup.DataSource.Open "LDAP://" + DCServer + "/ CN=First Storage Group,CN=InformationStore,CN=" +
Server + ",CN=Servers,CN=First Administrative Group, CN=Administrative Groups,CN=First Organization,
-identity “First Storage Group“
Mgmt CN=Microsoft Exchange,CN=Services, CN=Configuration," + DomainName
–log "C:\newlogPath”
StorGroup.MoveLogFiles("C:\newlogPath", 0)
Recipie Dim objMailbox As CDOEXM.IMailboxStore
enable-mailbox
nt Set objMailbox = GetObject("LDAP://" + DCServer + "CN=FOO,CN=users," + DomainName) -identity domain\FOO
Mgmt objMailbox.CreateMailbox "LDAP://" + DCServer + "/CN=Private MDB,CN=First Storage –database “First Storage
Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group,
CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services, CN=Configuration,"
+ DomainName
Group\Private MDB”
PowerShell Overview
The Purpose for PowerShell
Launching PowerShell for administrator
Customize the shell for comfort
Getting familiar with Shell
The Purpose to PowerShell
YOU THEM
Improved management and automation
Manage real-time
Manage large scale
Launching PowerShell for the Administrator
Customize the shell for comfort
Getting Familiar with the Shell
Cmdlets - Verb-Noun
Native Commands - Ping, IPConfig, Calc, Notepad, mspaint
cls – Clear-Host
Cd – Set-Location
Dir, ls – Get-ChildItem
Type, cat – Get-Content
Copy, cp – Copy-Item
Move, mv – Move-Item
Help Overview
Why you need help
Updatable Help
Discoverability with the Help system
Understanding Syntax
Real-World using Help
Why you need help
Vast resource at your finger tips to help make you successful
Don’t memorize – Discover!
Thousands of cmdlets – all have help!
Scripting resources and information
Advanced PowerShell configuration information
Updatable Help
Update to the latest version of Help
Save-Help to save to a local location
Discoverability with the Help system
Get-Help versus Help and Man
Help <cmdlet>
Help *partial*
Help <verb/noun>
Help <cmdlet> -Full
Help <cmdlet> -Online
Help <cmdlet> -ShowWindow
Get-Help About_*
Understanding Syntax
• Parameter sets
The meaning of Syntax
- Indicates A Parameter [] Argument Accepts Multiple Values [Param] is Positional
<> Indicates Arguments [Param Arg] is Optional
Real-World using Help
Q&A