This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#combien d'éléments à sauvegarder ? | |
$limit=5 | |
ls $SourceDir |sort lastwritetime -desc |select -skip $limite # | remove-item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$col=@() | |
#... | |
# instead adding an hashtable to the collection, we convert it to psobject | |
$prop=@{"serveur"="$computername";"nom"="$n";"programme"="$p";"arguments"="$a"; "xml"="$x"} | |
$col+= new-object -type pscustomobject -property $prop | |
#this allow us to export data to csv | |
$r |select serveur,nom,programme, arguments,xml |export-csv -path c:\temp\tasks.csv -notype -delimiter ';' -append |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#exemple pour extraire une adresse IP | |
$ipaddress=[regex]::match($awsoutput,"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b").Value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# replace versionnumber="xxx" whith versionnumber="yyy" | |
(gc C:\temp\config.xml) -replace '(newversion=)".*"' ,'$1"yyy"' # if you want to save the file add |sc c:\temp\config.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] #make script react as cmdlet (-verbose etc..) | |
param( | |
[Parameter(Position=0, Mandatory=$true,ValueFromPipeline = $true)] | |
[ValidateNotNullOrEmpty()] | |
[System.String] | |
$service, | |
[Parameter(Position=1)] | |
[System.string] | |
$computername="local" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create task from its xml definition | |
$sch = New-Object -ComObject("Schedule.Service") | |
$sch.connect("computername") | |
$root=$sch.GetFolder("\") | |
$root.CreateFolder("subfolder") | |
$folder =$sch.GetFolder("\subfolder") | |
#import .xml | |
Get-childItem -path $task_path -Filter *.xml | %{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Templata.ps1 | |
# author: Loic MICHEL | |
# date: 10/09/2013 | |
# abstract: make all errors terminating errors and send email + raise event in case of failure | |
# | |
[CmdletBinding()]param( | |
) |
NewerOlder