Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////
- Get-Process |
- Select-Object Name,
- ID,
- @{n='VirtualMemory(MB)';e={$PSItem.VM/ 1MB}},@{n='PagedMemory(MB)';e={$PSItem.PM/ 1MB}}
- ///////////////////
- Get-Volume | Where-Object -Filter { $PSItem.HealthStatus -eq 'Healthy' -or $PSItem.SizeRemaining -gt 100MB }
- ///////////////////
- Get-Volume | Where-Object -Filter { $_.HealthStatus -eq 'Healthy' -or $_.SizeRemaining -gt 100MB }
- ///////////////////
- Get-Service -ComputerName "localhost", "WIN-THODEPOGFK1"| Format-Table -Property MachineName, Status, Name, DisplayName -auto
- ///////////////////
- function WLog
- {
- param([string]$Log, [bool]$bligne=$false)
- if ($bligne)
- {
- Add-Content -Path ($Destination +'Log.log') -Value '---------------------------------------------------'
- Write-Host '---------------------------------------------------'
- if ($bDebug)
- {
- Read-Host $Log
- }
- }
- [string]$Dat = Get-Date
- $log2 = $Dat + ' -> ' + $Log
- Add-Content -Path ($Destination +'Log.log') -Value $Log2
- Write-Host $Log2
- }
- --------------------------------------------------------------------------------------
- Try
- {
- $Result = Copy-Item -Path 'C:\Test\toto.txt' D:\Perso -ErrorAction Stop
- }
- catch
- {
- write-host $Error[0]
- }
- Write-Host 'Fin'
- --------------------------------------------------------------------------------------
- function Copy-File {
- param( [string]$from, [string]$to)
- $ffile = [io.file]::OpenRead($from)
- $tofile = [io.file]::OpenWrite($to)
- Write-Progress -Activity "Copying file" -status "$from -> $to" -PercentComplete 0
- try {
- [byte[]]$buff = new-object byte[] 4096
- [int]$total = [int]$count = 0
- do {
- $count = $ffile.Read($buff, 0, $buff.Length)
- $tofile.Write($buff, 0, $count)
- $total += $count
- if ($total % 1mb -eq 0) {
- Write-Progress -Activity "Copying file" -status "$from -> $to" `
- -PercentComplete ([int]($total/$ffile.Length* 100))
- }
- } while ($count -gt 0)
- }
- finally {
- $ffile.Dispose()
- $tofile.Dispose()
- Write-Progress -Activity "Copying file" -Status "Ready" -Completed
- }
- }
- --------------------------------------------------------------------------------------
- ///////////////////
- 'Date: 02/09/2013' –match '^Date:\s(?<date>(?<jour>\d{2})/>(?<mois>\d{2})/>(?<annee>\d{4}))$'
- [string[]]$Jours='Lu','Ma','Me','Je','Ve','Sa','Di'
- $Jours[0]
- $Jours[-1]
- $jours.Length
- $jours+='Dredi'
- $Jours[-1]
- If($res|Where {$_ -match 'IPv4[ \.]+:[ ]+(\d+\.\d+\.\d+\.\d+)'}) {
- $Matches[1]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement