Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Version 1.0[edit]edit  Version 1.0 was released in 2006 for Windows XP SP2/SP3, Windows Server 2003,

Similar presentations


Presentation on theme: " Version 1.0[edit]edit  Version 1.0 was released in 2006 for Windows XP SP2/SP3, Windows Server 2003,"— Presentation transcript:

1

2 http://en.wikipedia.org/wiki/Windows_PowerShell  Version 1.0[edit]edit  Version 1.0 was released in 2006 for Windows XP SP2/SP3, Windows Server 2003, and Windows Vista. For Windows Server 2008, it is included as an optional featureWindows XPWindows Server 2003Windows VistaWindows Server 2008  Version 2.0[edit]edit  Windows PowerShell ISE, with multiple open PowerShell sessions (RunSpaces) in the Windows PowerShell 2.0.  Version 2.0 is integrated with Windows 7 and Windows Server 2008 R2 and is released for Windows XP with Service Pack 3, Windows Server 2003 with Service Pack 2, andWindows Vista with Service Pack 1. [40]Windows 7Windows Server 2008 R2Windows XPWindows Server 2003Windows Vista [40]  Microsoft released PowerShell 2.0 with Windows 7 and Windows 2008 R2. Windows PowerShell 2.0 is installed by default on Windows Server 2008 R2 (except on Core installations where it is optional) and Windows 7. [41] For older platforms it is available via the Windows Management Framework. [42] PowerShell V2 includes changes to the scripting language and hosting API, in addition to including more than 240 new cmdlets. [43][44]Windows Server 2008 R2Windows 7 [41] [42] [43][44]  Version 3.0[edit]edit  Version 3.0 is integrated with Windows 8 and with Windows Server 2012. Microsoft has also made PowerShell 3 available forWindows 7 with Service Pack 1, for Windows Server 2008 with Service Pack 1, and for Windows Server 2008 R2 with Service Pack 1. [51][52]Windows 8Windows Server 2012Windows 7Windows Server 2008Windows Server 2008 R2 [51][52]  Version 4.0[edit]edit  Version 4.0 is integrated with Windows 8.1 and with Windows Server 2012 R2. Microsoft has also made PowerShell 4 available forWindows 7 SP1, Windows Server 2008 R2 SP1 and Windows Server 2012. [55]Windows 8.1Windows Server 2012 R2Windows 7 SP1Windows Server 2008 R2Windows Server 2012 [55]

3  Type powershell in the cmd line  Navigate through the start menu  Use Window-R and type "PowerShell ISE" to start the PowerShell ISE.  http://social.technet.microsoft.com/Forums/en-US/56e2ef15-66fc-4af7-acc5-21fdc98438f8/where- is-the-powershell-ise?forum=W8ITProPreRel http://social.technet.microsoft.com/Forums/en-US/56e2ef15-66fc-4af7-acc5-21fdc98438f8/where- is-the-powershell-ise?forum=W8ITProPreRel

4  Get-ExecutionPolicy  Set-ExecutionPolicy Restricted  Nothing will run RemoteSigned  Runs stuff you create and stuff from the internet only if it’s signed from a trusted publisher AllSigned  Anything run must be signed by a trusted publisher Unrestricted  Runs everything like a real cowboy  Get-Help About_signing

5  What’s a cmdlet? It’s a tiny tiny little command Instances of.NET Framework classes; not stand- alone executables.  Verb-Noun Get-Process Remove-Website Stop-Job  Noun is not plural

6  Tab lets you scroll through items  F5 will execute like in SSMS but will execute everything not just the highlighted section  If the results don’t fit in the window, stretch it out or write to a file, or pipe it and format it

7  Get-Help Get-Help Nameof-Cmdlet -full  Displays the entire help topic for a cmdlet, including parameter descriptions and attributes, examples, input and output object types, and additional notes. -detailed  Adds parameter descriptions and examples to the basic help display -example  Displays only the name, synopsis, and examples -online  Opens technet article which is where I stole the descriptions  http://technet.microsoft.com/library/hh849696.aspx http://technet.microsoft.com/library/hh849696.aspx

8  How can I break things? Get-command shows you all of the easy out of the box ways you can destroy Get-process, Get-service, etc shows what you can easily destroy Stop-Process -ProcessName explorer -Force -whatif  Don’t just run things from the internet, and try to use whatif or confirm when you can.  Anything in your domain you have permissions to use, you can query, modify or delete WMI, Files, The Registry, Eventlog, SQL Server, Exchange, Active Directories, VMWare

9  -ComputerName Get-EventLog system –ComputerName THENAME  Some cmdlets restrict you from directly calling -ComputerName, you can use Invoke- Command and bracket them Invoke-Command -ComputerName Server01 {Stop- Process Powershell}  Use a servers list in a variable

10  Pass your data to another cmdlet for filtering or modification  Get-Service | Sort-Object Status | Format-Table  Get-EventLog application | Where- Object {$_.source -like "*SQL*"} | Format-Table EventID, MachineName, TimeWritten, Message

11  $ Use this for most variables. Variables are automatically declared  = This is how you set variables You can also use the set-variable cmdlet if you like typing  There are special variables Get-Help about_automatic_variables  There are reserved words Get-Help about_Language_Keywords  There are operators and arrays  More info http://www.powershellpro.com/powershell-tutorial- introduction/variables-arrays-hashes/ http://www.powershellpro.com/powershell-tutorial- introduction/variables-arrays-hashes/

12  Can make code succinct  Get-Alias lists all of the aliases that are built in, set/imported, or added to your profile

13  Yes!  Import Get-Content c:\files\test.txt $f = Import-CSV c:\files\test.csv –delimiter '|' $f | Select-Object Column2,Column3,Column6 | Format-Table  Export Export-CSV c:\scripts\test.csv Export-Clixml c:\scripts\test.xml Out-DataTable | Write-DataTable  http://gallery.technet.microsoft.com/ScriptCenter/en-us/2fdeaf8d-b164-411c-9483-99413d6053ae http://gallery.technet.microsoft.com/ScriptCenter/en-us/2fdeaf8d-b164-411c-9483-99413d6053ae

14  You can run Powershell from the ISE or cmd line manually powershell.exe -noexit &'c:\my scripts\test.ps1'  -noexit keeps the window open  Ampersand tick lets you pass files that have spaces in the filepath  But you can also Run as Windows schedule task Run as SQL Agent job Run as a GPO Logon script Nest in a.bat file Xp_cmdshell SSIS

15  Why do I care about Profiles? Pre runs commands to help quickly configure your powershell environment. Quickly load modules, aliases, functions, change the file path of your working folder, ect.  Where is the profile? Run: $profile Will give you a result something like: C:\Users\USERNAME\Documents\WindowsPowerShell\Microsoft.PowerShell_ profile.ps1

16  SQLPSX http://sqlpsx.codeplex.com/  Automatic Download it, install the msi and import the modules with import-module  Manual Download it, unzip file copy files to My Documents\WindowsPowerShell\Modules\ Type get-module –listAvailable Add the import-module cmdlets to your profile Has a bunch of built in admin functions  add a login? Run a query? Copy a SSIS package from File to DB? Run a backup? Change permissions?  Querying is as easy as get-isdata 'Z002\SQL2K8' pubs 'select * from authors'

17  Built on.NET and all objects are available  Full access to COM and WMI  Access to WS-Management and CIM  Also contains an API so powershell runtime can be embedded in other applications

18 Running Windows PowerShell Scripts http://technet.microsoft.com/en-us/library/ee176949.aspx Hey Scripting Guy! https://blogs.technet.com/b/heyscriptingguy/ Website/URL monitor http://dmitrysotnikov.wordpress.com/2008/05/29/monitor-web-site-availability/ SQL Agent Jobs excel report http://www.mssqltips.com/sqlservertip/1798/checking-sql-server-agent-jobs-using-windows-powershell/ Drive space report https://www.simple-talk.com/content/print.aspx?article=1339 Write datatable http://gallery.technet.microsoft.com/scriptcenter/2fdeaf8d-b164-411c-9483-99413d6053ae Technet script repository http://gallery.technet.microsoft.com/scriptcenter/site/search?f%5B0%5D.Type=ProgrammingLanguage&f%5B0%5D.V alue=PowerShell Forums Spiceworks http://community.spiceworks.com/programming/powershell Powershell.org http://powershell.org/wp/forums/topic/discussion:-logging-module/ SSC http://www.sqlservercentral.com/Forums/Forum1351-1.aspx


Download ppt " Version 1.0[edit]edit  Version 1.0 was released in 2006 for Windows XP SP2/SP3, Windows Server 2003,"

Similar presentations


Ads by Google