Your SlideShare is downloading. ×
0
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
PowerShell crashcourse for Sharepoint admins
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

PowerShell crashcourse for Sharepoint admins

612

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
612
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Windows PowerShellCrash Course forSharePoint Administrators<br />Don JonesConcentrated Technology, LLChttp://concentratedtech.com<br />
  • 2. This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like.<br />For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, www.ConcentratedTech.com. <br />For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg<br />This work is copyright ©Concentrated Technology, LLC<br />
  • 3. CAUTION: DEMOS AHEAD<br />This is a demonstration-intensive session (very few slides)<br />I will capture a shell transcript and save all of my scripts<br />You can download these (in a week or so) from ConcentratedTech.com (there’s a “Conference Materials” link in the menu)<br />
  • 4. Welcome to the Shell<br />Why did Microsoft write PowerShell?<br />Is this a replacement for Cmd.exe or VBScript?<br />How much “scripting” do I need to learn?<br />How long will PowerShell be around?<br />What versions of Windows does it work with?<br />What MS products are PowerShell-ed?<br />
  • 5. Command Quiz<br />Change directories<br />Make a directory<br />Get a list of files and folders<br />Display contents of a text file<br />Move a file<br />Copy a file<br />Delete a file<br />
  • 6. Running Commands<br />Run all the commands you’re used to, with almost exactly the same syntax (Ping, Ipconfig, etc)<br />New “cmdlets” have a more consistent naming convention and more consistent parameters… but they’re just commands<br />Use Help to read more; add –full or –examples for even more help; use wildcards to discover more commands and help topics<br />
  • 7. One Set of Commands<br />The file system is a hierarchical data store<br />What other data stores does Windows use?<br />Why not treat them as “disk drives” so that you can use the same set of commands?<br />
  • 8. Extending the Shell<br />PSSnapins (the old way)<br />Get-PSSnapin –registered<br />Add-PSSnapinname<br />Get-Command –pssnapinname<br />Modules (the new way)<br />Get-Module –listavailable<br />Import-Module name<br />Get-Command –module name<br />There’s only one shell – the “pre-made shells” are just pre-loading a snap-in or module for you<br />
  • 9. Piping<br />Just like Dir | More<br />Export-, Out-, Format-, ConvertTo- are all useful verbs for piping<br />Tip: Format- cmdlets go at the end of the pipeline. What they produce is only useful to Out-File, Out-Printer, Out-Host.<br />
  • 10. Output<br />Run Get-Process<br />See the resulting table?<br />The real table, in memory, is much bigger – PowerShell just doesn’t show it<br />Pipe the table to Get-Member to see other available columns<br />Or pipe it to Format-List * (since a list can hold more data than a table)<br />You don’t have to pipe stuff to a file and then grep it; you can simply refer to columns by name<br />
  • 11. More Piping<br />Sorting: Sort-Object (or “Sort”)<br />Filtering: Where-Object (or “Where”)<br />Grouping: Group-Object (or “Group”)<br />Measuring: Measure-Object (or “Measure”)<br />Use Format- cmdlets to specify the columns (called “properties”) that you’d prefer to see<br />
  • 12. Phys Ed<br />Let’s see the pipeline work in real life.<br />Volunteers needed. You may win a prize.<br />
  • 13. How Pipeline input works<br />Get-Service generates what type of table (ok, these are really “objects” and not a “table in memory,” but it’s all just words)<br />Get-Service | Get-Member<br />So when you runGet-Service | Stop-Servicehow does Stop-Service know what to do with what you piped in?<br />
  • 14. Pipeline Input ByValue<br />Look at the parameters of Stop-Service<br />Do any of them accept pipeline input ByValue and accept the type of data being produced by Stop-Service?<br />
  • 15. Now Consider This<br />“BITS”,”w32time” | Stop-Service<br />Those are strings“BITS” | Get-Member<br />Does Stop-Service accept anything of the type String ByValue from the pipeline?<br />This would work too:Get-Content names.txt | Stop-Service<br />World this work?Get-Process | Stop-ServiceHmmm…<br />
  • 16. Pipeline Input ByPropertyName<br />If nothing will work ByValue, then the shell tries to match up input columns with parameter names ByPropertyName<br />Let’s look atGet-Process | Get-Member<br />Do any of those column names match up with parameter names of Stop-Service?<br />Do the matching parameter names accept input from the pipeline ByPropertyName?<br />
  • 17. Debugging Pipeline Input<br />Trace-Command-Name PipelineBinding-PSHost-expression { Get-Process | Stop-Service }<br />
  • 18. Fun trick!<br />Import user info from a CSV and make new users out of them<br />
  • 19. Workarounds<br />What about when pipelining won’t work?<br />Get-WmiObject-class Win32_BIOS-computername (type names.txt)<br />Get-WmiObject-class Win32_BIOS-computername ( Get-ADComputer –filter * | Select –expand Name)<br />
  • 20. Remote Control<br />Requires PSH v2<br />Run Enable-PSRemoting to enable(or via GPO) on machines that will accept incoming connections<br />Communicates over HTTP(s); authenticates with Kerberos<br />Help about_remote* for more help<br />
  • 21. 1:1, 1:n Remoting<br />Enter-PSSession –computernamexExit-PSSession<br />Invoke-Command-scriptblock { command(s) }-computernamex,x,x,x<br />Notes:<br />PSComputerName property<br />FilePath switch to do a whole script<br />
  • 22. More Options<br />-credential<br />-port<br />-useSSL<br />Etc<br />Or create a persistent session using New-PSSession.<br />Get the sessions with Get-PSSessionInvoke-Command –scr { whatever }-session (Get-PSSession)<br />
  • 23. Implicit Remoting<br />Start a session (maybe save it in a $variable for ease of referring to it)<br />Import a module in the remote session<br />Import the remote session into the local shell – just the commands from that module, and add a noun prefix<br />Execute remote commands as if they were local!<br />
  • 24. WMI<br />Get-WmiObject-class whatever (e.g., “Win32_XXX”)-computername x,y,z-EA SilentlyContinue (why?)-Filter ”something” (why?)<br />Let’s play with that…<br />
  • 25. Awesome Advanced Trick<br />Format-Table can accept a special item called a hashtable or dictionary as a property in a property list<br />The dictionary must contain two items<br />N: The name of the column you want to create<br />E: The value to go into the columnThis can even be an entirely new command!Use $_ to refer to whatever table row (object) is current<br />Use to combine WMI info from two classes into a single output! Crazy syntax, but crazy useful!<br />
  • 26. NOW… let’s do some Q&amp;A<br />I’ve got more demos to show you, but want to make sure I address your questions<br />Ask ‘em now!<br />The remainder of the session will be additional demos<br />Remember: Transcript will be downloadable; no need to copy down the syntax<br />Ask for a “reminder card” if you want to download this stuff next week.<br />
  • 27. Final Notes…<br />Please be sure to submit a session evaluation form!<br />Download slides &amp; materials from www.ConcentratedTech.com within one week!<br />Blog, URLs, and other information is also available at www.ConcentratedTech.com for your reference<br />More resources at www.ShellHub.com<br />Thank you very much!<br />
  • 28. Your Feedback is Important<br />Please fill out a session evaluation form.<br />Thank you!<br />
  • 29. This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like.<br />For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, www.ConcentratedTech.com. <br />For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg<br />This work is copyright ©Concentrated Technology, LLC<br />

×