Beruflich Dokumente
Kultur Dokumente
17 mai 2010
Preinstalat pe Windows 7
Microsoft .NET Framework 3.5
MSSR
Windows PowerShell
Command line
Orientat pe obiecte
Comenzi verb-noun,
demunite cmdlets
Scripting Language
Automation Engine
MSSR
Windows PowerShell
Command line
Scripting Language
Scripturile nu ruleaza
implicit
Automation Engine
PowerShell Integrated
Scripting Environment
MSSR
Windows PowerShell
Command line
Poate fi integrat cu
aplicatiile .NET
Scripting Language
Folosit pentru
administrarea remote a
calculatoarelor
Automation Engine
MSSR
Cmdlets
.NET
Comenzi de baz
get-command
get-help
get-member
get-psdrive
exemplu
PS C:\> get-command ls
CommandType
----------Alias
Name
Definition
----
----------
ls
Get-ChildItem
MSSR
Comenzi de baz
get-command
get-help
get-member
help - full
get-psdrive
help examples
help online
Comenzi de baz
get-command
get-help
afiseaza proprietatile si
metodele unui obiect
Exemplu
C:\PS>get-service | getmember
get-member
get-psdrive
MSSR
Comenzi de baz
get-command
get-help
get-member
get-psdrive
10
afiseaza resursele
disponibile pentru
sesiunea curenta
dispozitivele logice,
inclusiv cele mapate din
retea
accesarea registrilor
Actiune
Compare
Group
Measure
Select
Sort
Ordonarea obiectelor
Tee
Duplicarea rezultatului
Where
11
MSSR
Alias-uri
Name
Definition
---------Get-ChildItem
Get-ChildItem
Get-ChildItem
CommandType
----------- ---Alias
dir
Alias
gci
Alias
ls
12
MSSR
Pipeline si variabile
$current_process = Get-Process
13
MSSR
Parametrii
Operator
Descriere
-eq
Equals
-match
-ne
Not Equal
-notmatch
-gt -ge
-lt -le
Exemplu
14
$current_process = Get-Process
if ($current_process.count -lt 50)
{ Write-Host Low server load"; }
MSSR
Sintaxa
Exemple
15
MSSR
WMI support
Windows Management Instrumentation
baza de date cu informatii pentru sistemele windows
serviciu wmi folosit pentru interogarea bazei de date
namespace-ul folosit este root\CIMV2
16
MSSR
[System.Console]::Clear()
[System.Math]::Log10(100)
$p = [System.Diagnostics.Process]::Start("notepad.exe")
$p | Get-Member
[System.Int32]::Parse("254");
17
http://msdn.microsoft.com/en-us/library/ms229335%28v=VS.90%29.aspx
MSSR
Scripturi powershell
Set-ExecutionPolicy
18
Restricted (implicit)
AllSigned
RemoteSigned
Unrestricted (nerecomandat)
MSSR
Exemplu script
$NIC.EnableStatic(192.168.+$i+.42, 255.255.255.0)
$NIC.SetGateways(192.168.+$i+.1)
$DNSServers = 198.102.234.125,198.102.234.126
$NIC.SetDNSServerSearchOrder($DNSServers)
$NIC.SetDynamicDNSRegistration(TRUE)
$NIC.SetWINSServer(198.102.234.125, 198.102.234.126)
$i ++
}
19
MSSR
Background jobs
Start-job
Get-job
receive-job -job $j
Stop-job
Receive-job
stop-job MyJob
Remove-job
20
remove-job MyJob
MSSR
[enum]::GetNames([System.Security.AccessControl.FileSystemRig
hts])
$SD.AddAccessRule($Rule)
21
$rule = new-object
System.Security.AccessControl.FileSystemAccessRule(guest,FullContr
ol, Allow)
Accesarea registrilor
Afisarea continutului
Get-ChildItem
Afisarea proprietatilor
Set-location HKCU:
$path=HKLM:\Software\Microsoft\Windows NT\CurrentVersion
$key = Get-ItemProperty $path
$key.ProductName
22
MSSR
Interesting scripting
$path = $env:temp\testfile.txt;
$file = [io.file]::Create($path);
$file.SetLength(1gb);
$file.Close();
Get-Item $path;
23
MSSR