Recettes PowerShell
De Linuxmemo.
(Différences entre les versions)
(→Tester l’exécution administrateur) |
(→MD5sum) |
||
Ligne 15 : | Ligne 15 : | ||
==MD5sum== | ==MD5sum== | ||
(Get-FileHash -Path ${repbase}${repdiffusion}\${nomfichier} -Algorithm MD5).hash | (Get-FileHash -Path ${repbase}${repdiffusion}\${nomfichier} -Algorithm MD5).hash | ||
+ | |||
+ | ==ZIP / UNZIP == | ||
+ | compress-archive -path 'c:\wwwroot\logs' -destinationpath '.\logs.zip' -compressionlevel optimal | ||
+ | compress-archive -path “c:\wwwroot\logs\latest” -destinationpath “c:\wwwroot\logs\logs.zip” -update -compressionlevel optimal | ||
+ | compress-archive test.txt test.zip | ||
+ | |||
+ | expand-archive -path 'c:\users\john\desktop\iislogs.zip' -destinationpath '.\unzipped' |
Version du 4 avril 2018 à 08:46
Sommaire |
Exécuter une commande stocké dans une variable
Invoke-Command -ComputerName $Ip -Credential $login -ScriptBlock { Param( $LocalVariable ); Invoke-Expression -Command $LocalVariable } -ArgumentList $commande
Tester l’exécution administrateur
function Test-Administrator { $user = [Security.Principal.WindowsIdentity]::GetCurrent(); (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) } Test-Administrator False
MD5sum
(Get-FileHash -Path ${repbase}${repdiffusion}\${nomfichier} -Algorithm MD5).hash
ZIP / UNZIP
compress-archive -path 'c:\wwwroot\logs' -destinationpath '.\logs.zip' -compressionlevel optimal compress-archive -path “c:\wwwroot\logs\latest” -destinationpath “c:\wwwroot\logs\logs.zip” -update -compressionlevel optimal compress-archive test.txt test.zip
expand-archive -path 'c:\users\john\desktop\iislogs.zip' -destinationpath '.\unzipped'