fabrice romelard [mvp] intranet – extranet cto sgs
Post on 20-Dec-2015
219 views
TRANSCRIPT
![Page 1: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/1.jpg)
Powershell V2Code Session: C101
Fabrice Romelard [MVP]Intranet – Extranet CTOSGS
![Page 2: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/2.jpg)
Presentation
MVP since 2003ASP.NET 2003-2006SQL Server 2006-2008SharePoint since 2008
French communities memberASP-PHPCodes SourcesGUSS
SharePoint Expert, SQL Server DBA and .NET developerCoworkers SGS at Geneva (Suisse)
![Page 3: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/3.jpg)
Survey
Who know PowerShell ?
Who know SharePoint ?
![Page 4: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/4.jpg)
Schedule
What’s SGS ?
What’s PowerShell ?
What’s New in PowerShell V2
PowerShell and SharePoint
![Page 5: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/5.jpg)
A BRIEF HISTORY OF SGS
Founded in Rouen in 1878, under the name of Goldstück, Hainzé & Co.First registration as Société Générale de Surveillance in Geneva in 1919Growth by agglomerations of various companies which until 2002 had great degree of autonomyListed publicly in 1985Single share structure introduced in 2001Four significant shareholder groups
Famille A. Von Finck IFIL investmentAllianz SE FMR Corp
![Page 6: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/6.jpg)
OUR IMPARTIAL SERVICES WORK ACROSS INDUSTRIES AND GEOGRAPHIES
Inspection Verification Testing Certification
![Page 7: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/7.jpg)
THE WORLD’S LEADING INSPECTION, VERIFICATION, TESTING AND CERTIFICATION COMPANY
More than 50'000 employeesEurope, Middle East & Africa: 23’000 employeesAmericas: 11’300 employeesAsia/Pacific: 15’700 employees
A network of over 1’000 offices & laboratories
![Page 8: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/8.jpg)
OUR EXPERTISE AND ACTIVITIES
AGRICULTURAL SERVICESMINERALS SERVICESOIL, GAS & CHEMICALS SERVICESAUTOMOTIVE SERVICESLIFE SCIENCE SERVICESINDUSTRIAL SERVICESSYSTEMS & SERVICES CERTIFICATIONGOVERNMENTS AND INSTITUTIONS SERVICES
![Page 9: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/9.jpg)
SharePoint WSS Farms
![Page 10: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/10.jpg)
Schedule
What’s SGS ?
What’s PowerShell ?
What’s New in PowerShell V2
PowerShell and SharePoint
![Page 11: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/11.jpg)
Windows PowerShellNew command-line shell and scripting language
• As interactive and composable as BASH/KSH
• As programmatic as Perl/Python/Ruby
• As production oriented as AS400 CL/VMS DCL
• Allows access to data stores as easy to access as filesystem
![Page 12: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/12.jpg)
Universal Automation Environment
Automation FrameworksAutomation Frameworks
Automation Frameworks
Cmdlets
In-Proc, Local, Remote
In-Proc, Local, RemoteRuntime Engines
In-Proc, Local, RemoteRuntime Engines
Automation Platform (API)
ScriptingLanguage
Type Normalizers
Type Normalizers
Type Normalizers
Providers Events, Jobs, Transactions
Shells, ISEs, GUI s, ApplicationsUniversal• Interactive or programmatic• Wide range of OSes• Local or Remote• Single or Multi Machine• Synch or Asynch• Wide range of authentication mechanisms• .NET, native code, COM, WMI, ADSI, XML, ADO, WebServices, WSMAN, etc• Simple scripting to systems programming
Powered by a strong community
![Page 13: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/13.jpg)
Why powershell ??
Have better solution than standard « cmd.exe » (Evolution of MS-DOS)Replace Perl, KixStart or VBScript scripts, for execute simple tasks
PowerShell :Object OrientedCan use .Net objectsGive many command
![Page 14: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/14.jpg)
Object oriented
In classical environment, command execution results in text
In PowerShell each result is object. We can use also the attributes and methods
![Page 15: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/15.jpg)
Characteristics
.Net powered
Can call WSH, COM, and WMI objects with .Net objects
Many Commandlets
Standard in commands and parameters
![Page 16: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/16.jpg)
Configuration de PowerShell
Version 1.0Pre-requisites : Framework .Net 2.0Available for:
Windows Server2008
• A feature• Not available in « Server Core »
•x86•x64•IA64
Windows Server 2003 SP1
• An update between SP1 and SP2 (KB926139, 140, 141)• To download
•x86•x64•IA64
Windows Vista • Update (KB928439)• To download
•x86•x64
Windows XP SP2 • Need an update (KB926139, 140, 141)• To download
•x86•x64
http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx
![Page 17: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/17.jpg)
PowserShell commands
PowerShell commands named « cmdlets » (ie: command-applets).
One verb and a name with a dash (-),
Generic verb list(Get, Set, Add, Remove, etc.) with diferent name like Path, Variable, Item, Object etc.
Lot of name possible for commands
![Page 18: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/18.jpg)
Parameters
Diferent solutions for use parametersget-command -Name [string] -Type [CommandTypes] -Verb [string] -Noun [string]
Use “” if parameter have a space or special char
![Page 19: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/19.jpg)
Basic commands
First of all: « Get-Command ».
For help: Get-Help with command.
More help on command: « Get-Help Get-Command –detailed » with some examples « Get-Help Get-Command –full » with all technical informations
![Page 20: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/20.jpg)
Aliases
Command « Short Name» Alias «my_cmd» for the command « very-long-command-to-write».
Help shell Unix or cmd.exe users with their uses …
ls, more, pwd, etc. ls is the command alias for Get-ChildItem which shows the file or folder list.
![Page 21: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/21.jpg)
Variable use
A PowerShell variable is define by the prefix $ with the name and can receive value
We can create the named variable $current-process and store the active process list
$current_process = Get-Process
![Page 22: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/22.jpg)
The Pipe
Action between commands
PowerShell built for transition data between commands without change (more text transform)
Get-Process | where { $_.handlecount -gt 400 } | Format-List
![Page 23: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/23.jpg)
Conditions and operators
Condition in PowerShell, we can use operators If, ElseIf and Else
$current_process = Get-ProcessIf ($current_process.count -lt 50){ Write-Host « Low server load";}Elseif (($current_process.count -ge 50) -and ($current_process.count -lt 80)){ Write-Host « Middle server load";}Else{ Write-Host « High server load";}
![Page 24: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/24.jpg)
Loop use
We can create loop in PowerShell as While, Do While, For or Foreach.
$var = 1 // One variable set to 1while ($var -le 50) {$var; $var += 1} // while the value is not equal to 50, we add 1
for ($var = 1; $var -le 50; $i++) //
{$var} // each steps we show the variable value
![Page 25: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/25.jpg)
Objects use
WMI objectsInclude in PowerShell in standard, no creation needGet-WmiObject –list
.NET and COM objectsCreate a new object for a variablePS C:\> $xls = New-Object -ComObject Excel.ApplicationWe can use the methods and properties
![Page 26: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/26.jpg)
Windows PowerShell
Basic Scripts for Services and file management
demo
![Page 27: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/27.jpg)
Schedule
What’s SGS ?
What’s PowerShell ?
What’s New in PowerShell V2 ?
PowerShell and SharePoint
![Page 28: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/28.jpg)
PowerShell V2 Goals
Reduce the cost and effort to:Use PowerShell
Get, learn, share scripts
Layer applications on PowerShellGUI, web, workflow, etc.
Manage anything/everythingServers, clients, distributed systems, applications, web services, cloud services, raw HW, other OSes, everythingUsing any and all mechanisms (WMI, .Net, native code, web services, WSMAN)
![Page 29: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/29.jpg)
Pre-requisites
Microsoft .NET Framework 2.0
Windows PowerShell remoting et background jobs needs WinRM 2.0 CTP3 : Only for Vista SP1 and W2008
Windows PowerShell Integrated Scripting Environment (ISE) and Out-GridView cmdlet needs Microsoft .NET Framework 3.5 SP1
![Page 30: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/30.jpg)
Changes (1)
Windows PowerShell Remoting1:1 et 1:plusieurs
Background JobsAdvanced FunctionsModulesTransactions
![Page 31: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/31.jpg)
Changes (2)
Script DebuggingNouvelles CmdletsWindows PowerShell Integrated Scripting Environment (ISE)Nouveaux opérateurs
Splatting (@)SplitJoin
![Page 32: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/32.jpg)
Who Does What?V1 V2
Developer •Cmdlets and/or providers• Help
•PowerShell cmdlets •Transaction support
PowerShell • CLI & API
• Rich language w/access to com, wmi, .Net, adsi, xml & ado
• Utilities to manipulate, format, import/export
• 129 Cmdlets
•Web service & workflow activities
•Richer language w/access to web services, unmanaged code, wsman
• Richer utilities including eventing, job control, remote execution
• 241 Cmdlets
•Graphical ISE to create/debug scripts
Users •Simple ad hoc scripts•Sophisticated production scripting
•Systems programming•Across multiple machines
Community
• Write and share scripts • Write and Share Modules
V1 Scripts and Cmdlets run on PowerShell V2
![Page 33: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/33.jpg)
PowerShell V2 in Windows 7PowerShell V2 in Server Core
Announcing
![Page 34: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/34.jpg)
Managing Raw HW and Other OSes
Management initiative driven by DMTFPlatform independent, interoperable & industry standard management solutionCIM based standards for Server and Desktop managementWS-Management (WSMAN)
ITConsole
ManagedPlatforms
WSMAN
![Page 35: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/35.jpg)
Raw HW Management - Examples
Power control and boot control HW/ SW inventory Alerts and lifecycle events Config/manage BIOS Software and Firmware update Health monitoring
![Page 36: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/36.jpg)
Hardware Sample Commands
Power Off Command
Invoke-WSManAction -CN $svr -cred $cred -port 16992 `-Auth digest CIM_ComputerSystem `–Action RequestStateChange `–SelectorSet @{Name="ManagedSystem"} `-valueSet @{RequestedState="3"}
Chassis ClassGet-WSManInstance -CN $svr -cred $cred -port 16992 -Auth digest -enum CIM_Chassis
Chip ClassGet-WSManInstance –CN $srv -cred $cred -port 16992 -Auth digest -enum CIM_Chip
Power On Command
Invoke-WSManAction -CN $svr -cred $cred -port 16992 `-Auth digest CIM_ComputerSystem `–Action RequestStateChange `–SelectorSet @{Name="ManagedSystem"} `-valueSet @{RequestedState=“2"}
![Page 37: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/37.jpg)
Remote management
Remote WMI Remote Command/Script Execution Remote Background Jobs Remote Interactive Session
![Page 38: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/38.jpg)
Server list management
-ComputerName <string[]> # txt format list-Throttle <int> # fix parallel session number-AsJob # execut in background
PS> gwmi -CN (cat servers.txt) Win32_Bios -Throttle 64 | Select __Server, Name, Manufacturer, Version | ConvertTo-Html > BiosInventory.htm
PS> $job = gwmi -CN (cat servers.txt) Win32_Bios -Throttle 64 –AsJobPS> Wait-job $j # or go do something elsePS> Receive-Job $j | Select __Server, Name, Manufacturer, Version | ConvertTo-Html > BiosInventory.htm
![Page 39: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/39.jpg)
PowerShell V2
xxxxx
demo
![Page 40: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/40.jpg)
Schedule
What’s SGS ?
What’s PowerShell ?
What’s New in PowerShell V2 ?
PowerShell and SharePoint
![Page 41: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/41.jpg)
Use the SharePoint objects
Load the SharePoint DLL[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
Set the variable$site = new-object Microsoft.SharePoint.SPSite(“http://myWebApp”)
Use the MSDN site as the .NET SharePoint Development
![Page 42: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/42.jpg)
PowerShell & SharePoint
Scripts for SharePoint management
demo
![Page 43: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/43.jpg)
PowerShell V2
Conclusion
![Page 44: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/44.jpg)
Related LinksTechnical Blog
http://blogs.developpeur.org/fabrice69/Online Articles
http://www.asp-php.netSharePoint Management PowerShell scripts
http://sharepointpsscripts.codeplex.comPowerShell Blogs
http://blogs.technet.com/powershell/http://blogs.msdn.com/powershell/http://scriptingof.blogspot.com/
![Page 45: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/45.jpg)
PowerShell V2
Questions ?
![Page 46: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/46.jpg)
Save the date for tech·days next year!
14 – 15 avril 2010, CICG
![Page 47: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/47.jpg)
Classic Sponsoring Partners
Premium Sponsoring Partners
![Page 48: Fabrice Romelard [MVP] Intranet – Extranet CTO SGS](https://reader034.vdocuments.us/reader034/viewer/2022051516/56649d445503460f94a20350/html5/thumbnails/48.jpg)