SlideShare a Scribd company logo
Intro to PowerShellAdam PrestonSenior ConsultantDecember 4th, 2010
Adam Preston – Senior Consultant (TCSC)Born in Richmond, VACertified:MCITP: SharePoint 2010, AdministratorMCTS: SharePoint 2010, ConfigurationMCTS: Microsoft Office SharePoint Server 2007, ConfigurationMCTS: Microsoft Windows SharePoint Services 3.0, ConfigurationContact Information:Email: dap@tcsc.comTwitter: @_aprestonBlog: http://www.tcscblog.comWho is this guy?
Founded in 1981Based in Richmond, VAConsulting Services and Software Product DevelopmentConsulting Services has been specializing in SharePoint services for over 6 years (since v1)Consistently recognized for quality of technical servicesMicrosoft Worldwide Partner Conference Technology Innovation Award FinalistMicrosoft Mid-Atlantic Teamwork AwardMicrosoft Mid-Atlantic Loyalty AwardInfineon Technologies’ Technology Innovation AwardProviding Microsoft-centric consulting, application development and work management solutionsThe Computer Solution Company (TCSC)
AgendaWhat is PowerShell?Where do I find it?What are the benefits of PowerShell?Wait, what happened to STSADM?What commands will get me started?Who has permission to SharePoint 2010 w/PowerShell?Demos, Demos, and Demos!ReferencesQuestions
Windows PowerShell is Microsoft's task automation framework, consisting of a command-line shell and associated scripting language built on top of, and integrated with the .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems.DOS on Steroids!A modern replacement for the DOS command-line shellPowerShell
PowerShell 2.0 is built into Windows 7 and Windows Server 2008 R2For older OS’s, need to download Windows Management Framework to get PS 2.0Start > Accessories > Windows PowerShellSharePoint 2010 Management ShellSimply a shortcut to a profile that loads the SP2010 Provider SnapinPowerShell
Still there and still worksRemains for backwards compatibilityAllows for portability of existing STSADM batch files and scriptsSome commands have been removed (ex. all SSP related commands)Don’t use this as a crutch! You should start to do everything in PowerShell.Remember that it’s the “14 Hive” nowC:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BINPowerShell > STSADMNewly created cmdlets were developed for enhanced performancePowerShell has full access to the SharePoint API from the command lineSTSADM to Windows PowerShell Mapping:http://technet.microsoft.com/en-us/library/ff621081.aspxSTSADM?
Windows PowerShell Integrated Scripting Environment (ISE)Host application for PSCan run commands, write, test, and debug scriptsUses color-coding Only available with PS 2.0Server Manager > Add Features > Windows PowerShell ISENeeds to be installed in order to use Out-GridViewPowerShell ISE
Interact with .NET objects directlyRemoting interfaceSharePoint PowerShell Remoting RequirementsSharePoint Remoting with PowerShell 2.0Reduction in the need of some 3rd party solutionsPerform administrative functions in bulk, reducing time and effort.Will show an example of this in a later demoSome SharePoint 2010 functions require the use of PowerShell:Resetting the Farm PassphraseHow to Reset the Farm Passphrase in SharePoint 2010Configuring the State Service ApplicationConfiguring the Publishing Feature’s Super User AccountsPerformance benefits for batch operationsBenefits of PowerShell
Used to find all the commands available to PowerShellCmdlets generally have a verb-noun naming conventionGet-ChildItem, Get-Member, Add-SPSolution, Backup-SPFarm, Export-SPWebGet-Command -noun *infopath*Get-Command -noun *solution*List all available SP2010 cmdlets:Get-Command -PSSnapin “Microsoft.SharePoint.PowerShell”Get-Command
Used to show Synopsis, Syntax, Description, Parameters, and ExamplesSeveral ways to get help information on cmdlets:Get-Help <cmdlet>Get-Help Get-SPSite -fullGet-Help Get-SPSite -examplesGet-Help Get-SPSite–detailedGet-Help *-SPSite<cmdlet> -?Help <name> Ex. Help database, Help Get-SPSite, etc.PagingSome results will only show a subset  ending with “-- More --”<ENTER> = show next line or row<SPACE> = show next page or subsetCan create paging by piping results to “more”Get-SPSite | moreGet-Help
AliasesA way of calling a command using a keyword or abbreviationMost cmdlets have an associated alias  to allow for shortcuttingGet-Command = gcmFormat-List = flSet-Location = cdGet-ChildItem = dirUse Get-Alias to get a list of aliases available for your current sessionUse Set-Alias to create your own!Get-MemberGets the properties and methods of objectsGet-SPSite| Get-MemberUseful for when trying to determine what property you want to outputAliases and Get-Member
DemoNavigating PowerShell
PipelineAllows output of one cmdlet to be the input of another cmdletExamplesGet-Process | Format-Table Name, CPUGet-SPWebApplication | Get-SPSite | Get-SPWebSelect-ObjectAllows you to pick available properties instead of grabbing all propertiesGet-SPSite | Get-SPWeb | Select URL, WebTemplate, LastItemModifiedDateWhere-ObjectOnly display results which meet a certain conditionGet-SPLogEvent-StartTime (Get-Date).AddMinutes(-5) | Where-Object {$_.Level -eq “High”} Sort-ObjectSort the result set by one or more propertyGet-SPSite | Sort Owner, URLSort ascending (default) or descendingGet-SPSite | Select URL, Owner, LastContentModifiedDate | Sort LastContentModifiedDate -DescendingPipeline, Select, Where, and Sorting
Write-HostOutputs to PowerShell session windowWrite-WarningWrite-ErrorWrite-EventLogOut-FileOutputs to provided path locationCan use “>” as aliasOut-GridViewRequires PS ISEOut-PrinterSends to default printerExport-CSVExport-XMLWays to Output
Get-Command Format-*Format-ListResults are:Property1: ResultProperty2: ResultProperty3: ResultFormat-TableResults are:Property1Property2Property3Result			Result		  ResultFormat-WideOnly displays one property and puts it into multiple columnsFormatting
DemoResult Filtering, Output, and Formatting
Most Microsoft products expose their management interface through providersWindows, SharePoint, Exchange, IIS, SQL, Forefront, etc. IIS Example:Import-Module WebAdministrationSet-ItemProperty ‘IIS:\Sites\SharePoint – 80’ -Name LogFile.directory -Value ‘C:\Logs\IIS’Windows Example:New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa\MSV1_0 -Name “BackConnectionHostNames” -Value “intranet.contoso.com”,”mysites.contoso.com” -PropertyTypemultistringThis means that you could have your script or command interact with multiple applications at once. Scripting PowerShell allows for complex scripting, which include functions, loops, parameters, branching, and much more!Scripts are saved using the .PS1 file extensionRestricted by default, can change using Set-ExecutionPolicyBest Practice is to have your scripts signed, don’t leave your environment in an unrestricted statePowerShell Providers and Scripting
Out-of-the-box only the Farm Account has permission to interact with SharePoint 2010 via PowerShell. This does not include additional Farm Administrators.Get-SPShellAdminLists who has rights to run PowerShell commands against the databasesAdd-SPShellAdminMust be local admin, db_owner, and securityadmin to run this command properlyUser is added to WSS_Admin_WPG group on all WFEs and is added to the SharePoint_Shell_Access role on the database you specifiedAdd-SPShellAdmin -username  tcsc\dap -database Portal_Content_DBIf the database switch is not used, then the user is added access to the configuration databaseRemove-SPShellAdminRemove-SPShellAdmin -username tcsc\dapBe Careful!SP2010 PowerShell Permissions
DemoPermissions and SP2010 Commands
Bing Visual SearchSearch Bing for “PowerShell”, click top tab “Visual Search”
Windows PowerShell for SP2010 Resource CenterWindows PowerShell for SP2010 ReferencesTechNet Script Center RepositoryGetting Started with Windows PowerShell for SharePoint AdministratorsPowerShell Videos on Channel9Gary Lapointe’s Custom SharePoint 2010 PowerShell Cmdlets and STSADM CommandsMastering PowerShell (Free eBook - Over 560 Pages!)PowerShell Book(s)PowerShell for Microsoft SharePoint 2010 AdministratorsWindows PowerShell 2.0 Administrator’s Pocket ConsultantReferences
TCSC Office 2010 GiveawayTCSC is giving away copies of Microsoft Office 2010 Professional Plus3 Ways To Win (One copy max per person overall)Visit the new TCSC Blog www.tcscblog.comMake a comment on the SharePoint Saturday post with the words “SharePoint Saturday Rocks” in itFollow @TCSC on TwitterTweet “Rocking out with @TCSC at #SharePoint Saturday Richmond #spsric”Visit our booth and provide us your business card
Questions?

More Related Content

What's hot (20)

DOCX
Windows power shell for sharepoint online &amp; office 365
Prashant Kumar Singh
 
PPTX
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
Randy Williams
 
PDF
APEX Behind the Scenes by Scott Spendolini
Enkitec
 
PDF
CakePHP and AJAX
Mark Scherer
 
PPTX
SPFx Webinar Loading SharePoint data in a SPFx Webpart
Jenkins NS
 
PDF
Configure an Integrated Exchange, Lync, and SharePoint Test Lab
Vinh Nguyen
 
PDF
Hidden Gems in ColdFusion 2016
ColdFusionConference
 
PPTX
Share point 2013 installation step by step
prasslides
 
PPTX
Spstc2011 managed metadata real world
Atul Chhoda
 
PPT
Automated Testing Of Web Applications Using XML
diongillard
 
PDF
2 introduction-php-mvc-cakephp-m2-installation-slides
MasterCode.vn
 
PDF
Cakephp
Khalid Alharbi
 
PDF
Getting your grips on Excel chaos
Niels de Bruijn
 
PPTX
40+ tips to use Postman more efficiently
postmanclient
 
ODP
BP101 - 10 Things to Consider when Developing & Deploying Applications in Lar...
Martijn de Jong
 
PPTX
Using Visual Studio to Build SharePoint 2010 Solutions
Randy Williams
 
PPTX
ASP.NET 4.0
XeDotNet
 
PPTX
Integrating SharePoint with Exchange-2013
Randy Williams
 
PDF
Installing and Configuring Oracle Beehive Clients (whitepaper)
Revelation Technologies
 
PPTX
Share point 2010_overview-day4-code
Narayana Reddy
 
Windows power shell for sharepoint online &amp; office 365
Prashant Kumar Singh
 
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
Randy Williams
 
APEX Behind the Scenes by Scott Spendolini
Enkitec
 
CakePHP and AJAX
Mark Scherer
 
SPFx Webinar Loading SharePoint data in a SPFx Webpart
Jenkins NS
 
Configure an Integrated Exchange, Lync, and SharePoint Test Lab
Vinh Nguyen
 
Hidden Gems in ColdFusion 2016
ColdFusionConference
 
Share point 2013 installation step by step
prasslides
 
Spstc2011 managed metadata real world
Atul Chhoda
 
Automated Testing Of Web Applications Using XML
diongillard
 
2 introduction-php-mvc-cakephp-m2-installation-slides
MasterCode.vn
 
Getting your grips on Excel chaos
Niels de Bruijn
 
40+ tips to use Postman more efficiently
postmanclient
 
BP101 - 10 Things to Consider when Developing & Deploying Applications in Lar...
Martijn de Jong
 
Using Visual Studio to Build SharePoint 2010 Solutions
Randy Williams
 
ASP.NET 4.0
XeDotNet
 
Integrating SharePoint with Exchange-2013
Randy Williams
 
Installing and Configuring Oracle Beehive Clients (whitepaper)
Revelation Technologies
 
Share point 2010_overview-day4-code
Narayana Reddy
 

Similar to Intro to PowerShell (20)

PPTX
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
SharePoint Saturday NY
 
PPTX
NZ Code Camp 2011 PowerShell + SharePoint
Nick Hadlee
 
DOCX
Power shell
Rajkiran Swain
 
PPTX
Admin share point with powershell
Concentrated Technology
 
PPTX
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
SPTechCon
 
PDF
Automating Your Enterprise Application Deployments with PowerShell
Geoff Varosky
 
PPTX
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Michael Blumenthal (Microsoft MVP)
 
PPTX
Spstc2011 managed metadata real world
Atul Chhoda
 
PPTX
Automating PowerShell with SharePoint
Talbott Crowell
 
PPTX
Best practices and tools for PowerShell and SharePoint Scripting SharePointFe...
Michael Blumenthal (Microsoft MVP)
 
PPT
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
PPTX
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
Comunidade Portuguesa de SharePoiint
 
PPT
STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...
Joel Oleson
 
PPT
Automating Active Directory mgmt in PowerShell
Concentrated Technology
 
PPTX
Intro to SharePoint + PowerShell
Ryan Dennis
 
PPTX
SharePoint Administration: Tips from the Field
wahidsaleemi
 
PPTX
Automated server farm installation using psconfig and stsadm dm300 - curry ...
Vickey Bird
 
PPTX
Admin SharePoint 2010 with PowerShell
Concentrated Technology
 
PPTX
Mai Omar Desouki - SharePoint 2010 ITPRO
Mai Omar Desouki
 
PPTX
Tipstricksandbestpracticesformanagingmicrosoftofficesharepointserver2007 0905...
corin29
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
SharePoint Saturday NY
 
NZ Code Camp 2011 PowerShell + SharePoint
Nick Hadlee
 
Power shell
Rajkiran Swain
 
Admin share point with powershell
Concentrated Technology
 
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
SPTechCon
 
Automating Your Enterprise Application Deployments with PowerShell
Geoff Varosky
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Michael Blumenthal (Microsoft MVP)
 
Spstc2011 managed metadata real world
Atul Chhoda
 
Automating PowerShell with SharePoint
Talbott Crowell
 
Best practices and tools for PowerShell and SharePoint Scripting SharePointFe...
Michael Blumenthal (Microsoft MVP)
 
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
Comunidade Portuguesa de SharePoiint
 
STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...
Joel Oleson
 
Automating Active Directory mgmt in PowerShell
Concentrated Technology
 
Intro to SharePoint + PowerShell
Ryan Dennis
 
SharePoint Administration: Tips from the Field
wahidsaleemi
 
Automated server farm installation using psconfig and stsadm dm300 - curry ...
Vickey Bird
 
Admin SharePoint 2010 with PowerShell
Concentrated Technology
 
Mai Omar Desouki - SharePoint 2010 ITPRO
Mai Omar Desouki
 
Tipstricksandbestpracticesformanagingmicrosoftofficesharepointserver2007 0905...
corin29
 
Ad

Recently uploaded (20)

PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PDF
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
PDF
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
PPTX
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
PDF
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PPTX
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
Ad

Intro to PowerShell

  • 1. Intro to PowerShellAdam PrestonSenior ConsultantDecember 4th, 2010
  • 2. Adam Preston – Senior Consultant (TCSC)Born in Richmond, VACertified:MCITP: SharePoint 2010, AdministratorMCTS: SharePoint 2010, ConfigurationMCTS: Microsoft Office SharePoint Server 2007, ConfigurationMCTS: Microsoft Windows SharePoint Services 3.0, ConfigurationContact Information:Email: [email protected]: @_aprestonBlog: http://www.tcscblog.comWho is this guy?
  • 3. Founded in 1981Based in Richmond, VAConsulting Services and Software Product DevelopmentConsulting Services has been specializing in SharePoint services for over 6 years (since v1)Consistently recognized for quality of technical servicesMicrosoft Worldwide Partner Conference Technology Innovation Award FinalistMicrosoft Mid-Atlantic Teamwork AwardMicrosoft Mid-Atlantic Loyalty AwardInfineon Technologies’ Technology Innovation AwardProviding Microsoft-centric consulting, application development and work management solutionsThe Computer Solution Company (TCSC)
  • 4. AgendaWhat is PowerShell?Where do I find it?What are the benefits of PowerShell?Wait, what happened to STSADM?What commands will get me started?Who has permission to SharePoint 2010 w/PowerShell?Demos, Demos, and Demos!ReferencesQuestions
  • 5. Windows PowerShell is Microsoft's task automation framework, consisting of a command-line shell and associated scripting language built on top of, and integrated with the .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems.DOS on Steroids!A modern replacement for the DOS command-line shellPowerShell
  • 6. PowerShell 2.0 is built into Windows 7 and Windows Server 2008 R2For older OS’s, need to download Windows Management Framework to get PS 2.0Start > Accessories > Windows PowerShellSharePoint 2010 Management ShellSimply a shortcut to a profile that loads the SP2010 Provider SnapinPowerShell
  • 7. Still there and still worksRemains for backwards compatibilityAllows for portability of existing STSADM batch files and scriptsSome commands have been removed (ex. all SSP related commands)Don’t use this as a crutch! You should start to do everything in PowerShell.Remember that it’s the “14 Hive” nowC:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BINPowerShell > STSADMNewly created cmdlets were developed for enhanced performancePowerShell has full access to the SharePoint API from the command lineSTSADM to Windows PowerShell Mapping:http://technet.microsoft.com/en-us/library/ff621081.aspxSTSADM?
  • 8. Windows PowerShell Integrated Scripting Environment (ISE)Host application for PSCan run commands, write, test, and debug scriptsUses color-coding Only available with PS 2.0Server Manager > Add Features > Windows PowerShell ISENeeds to be installed in order to use Out-GridViewPowerShell ISE
  • 9. Interact with .NET objects directlyRemoting interfaceSharePoint PowerShell Remoting RequirementsSharePoint Remoting with PowerShell 2.0Reduction in the need of some 3rd party solutionsPerform administrative functions in bulk, reducing time and effort.Will show an example of this in a later demoSome SharePoint 2010 functions require the use of PowerShell:Resetting the Farm PassphraseHow to Reset the Farm Passphrase in SharePoint 2010Configuring the State Service ApplicationConfiguring the Publishing Feature’s Super User AccountsPerformance benefits for batch operationsBenefits of PowerShell
  • 10. Used to find all the commands available to PowerShellCmdlets generally have a verb-noun naming conventionGet-ChildItem, Get-Member, Add-SPSolution, Backup-SPFarm, Export-SPWebGet-Command -noun *infopath*Get-Command -noun *solution*List all available SP2010 cmdlets:Get-Command -PSSnapin “Microsoft.SharePoint.PowerShell”Get-Command
  • 11. Used to show Synopsis, Syntax, Description, Parameters, and ExamplesSeveral ways to get help information on cmdlets:Get-Help <cmdlet>Get-Help Get-SPSite -fullGet-Help Get-SPSite -examplesGet-Help Get-SPSite–detailedGet-Help *-SPSite<cmdlet> -?Help <name> Ex. Help database, Help Get-SPSite, etc.PagingSome results will only show a subset ending with “-- More --”<ENTER> = show next line or row<SPACE> = show next page or subsetCan create paging by piping results to “more”Get-SPSite | moreGet-Help
  • 12. AliasesA way of calling a command using a keyword or abbreviationMost cmdlets have an associated alias to allow for shortcuttingGet-Command = gcmFormat-List = flSet-Location = cdGet-ChildItem = dirUse Get-Alias to get a list of aliases available for your current sessionUse Set-Alias to create your own!Get-MemberGets the properties and methods of objectsGet-SPSite| Get-MemberUseful for when trying to determine what property you want to outputAliases and Get-Member
  • 14. PipelineAllows output of one cmdlet to be the input of another cmdletExamplesGet-Process | Format-Table Name, CPUGet-SPWebApplication | Get-SPSite | Get-SPWebSelect-ObjectAllows you to pick available properties instead of grabbing all propertiesGet-SPSite | Get-SPWeb | Select URL, WebTemplate, LastItemModifiedDateWhere-ObjectOnly display results which meet a certain conditionGet-SPLogEvent-StartTime (Get-Date).AddMinutes(-5) | Where-Object {$_.Level -eq “High”} Sort-ObjectSort the result set by one or more propertyGet-SPSite | Sort Owner, URLSort ascending (default) or descendingGet-SPSite | Select URL, Owner, LastContentModifiedDate | Sort LastContentModifiedDate -DescendingPipeline, Select, Where, and Sorting
  • 15. Write-HostOutputs to PowerShell session windowWrite-WarningWrite-ErrorWrite-EventLogOut-FileOutputs to provided path locationCan use “>” as aliasOut-GridViewRequires PS ISEOut-PrinterSends to default printerExport-CSVExport-XMLWays to Output
  • 16. Get-Command Format-*Format-ListResults are:Property1: ResultProperty2: ResultProperty3: ResultFormat-TableResults are:Property1Property2Property3Result Result ResultFormat-WideOnly displays one property and puts it into multiple columnsFormatting
  • 18. Most Microsoft products expose their management interface through providersWindows, SharePoint, Exchange, IIS, SQL, Forefront, etc. IIS Example:Import-Module WebAdministrationSet-ItemProperty ‘IIS:\Sites\SharePoint – 80’ -Name LogFile.directory -Value ‘C:\Logs\IIS’Windows Example:New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa\MSV1_0 -Name “BackConnectionHostNames” -Value “intranet.contoso.com”,”mysites.contoso.com” -PropertyTypemultistringThis means that you could have your script or command interact with multiple applications at once. Scripting PowerShell allows for complex scripting, which include functions, loops, parameters, branching, and much more!Scripts are saved using the .PS1 file extensionRestricted by default, can change using Set-ExecutionPolicyBest Practice is to have your scripts signed, don’t leave your environment in an unrestricted statePowerShell Providers and Scripting
  • 19. Out-of-the-box only the Farm Account has permission to interact with SharePoint 2010 via PowerShell. This does not include additional Farm Administrators.Get-SPShellAdminLists who has rights to run PowerShell commands against the databasesAdd-SPShellAdminMust be local admin, db_owner, and securityadmin to run this command properlyUser is added to WSS_Admin_WPG group on all WFEs and is added to the SharePoint_Shell_Access role on the database you specifiedAdd-SPShellAdmin -username tcsc\dap -database Portal_Content_DBIf the database switch is not used, then the user is added access to the configuration databaseRemove-SPShellAdminRemove-SPShellAdmin -username tcsc\dapBe Careful!SP2010 PowerShell Permissions
  • 21. Bing Visual SearchSearch Bing for “PowerShell”, click top tab “Visual Search”
  • 22. Windows PowerShell for SP2010 Resource CenterWindows PowerShell for SP2010 ReferencesTechNet Script Center RepositoryGetting Started with Windows PowerShell for SharePoint AdministratorsPowerShell Videos on Channel9Gary Lapointe’s Custom SharePoint 2010 PowerShell Cmdlets and STSADM CommandsMastering PowerShell (Free eBook - Over 560 Pages!)PowerShell Book(s)PowerShell for Microsoft SharePoint 2010 AdministratorsWindows PowerShell 2.0 Administrator’s Pocket ConsultantReferences
  • 23. TCSC Office 2010 GiveawayTCSC is giving away copies of Microsoft Office 2010 Professional Plus3 Ways To Win (One copy max per person overall)Visit the new TCSC Blog www.tcscblog.comMake a comment on the SharePoint Saturday post with the words “SharePoint Saturday Rocks” in itFollow @TCSC on TwitterTweet “Rocking out with @TCSC at #SharePoint Saturday Richmond #spsric”Visit our booth and provide us your business card

Editor's Notes

  • #16: (get-date).ToString()