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
#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
$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
#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
# some ways to remove empty lines when splitting strings | |
# for example | |
# $text = "Video Video Audio Audio VBI VBI" | |
# $text.Split() | |
# outputs this | |
# Video | |
# Video |
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
<# | |
PARSING (log) files. | |
when log files contains several colums on the same line we can use importfrom-csv | |
but how to do when log files is organized 'by lines' ? | |
example | |
Name: ENC1 | |
IPv4 Address: 172.16.2.101 | |
Link Settings: Forced, 100 Mbit, Full Duplex | |
Name: ENC2 |
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
# running dos command with lengthy parameters may sometimes be difficult to run from powershell | |
# one easy step that may correct the problem is to call cmd.exe /c before calling the command : | |
# this will not work | |
# & c:\windows\handle.exe /accepteula .d1 > C:\upf\logs\backup\handle.txt | |
# this is OK | |
start-process -Wait -NoNewWindow cmd.exe "/c handle.exe .d1 > C:\upf\logs\backup\handle.txt" | |
# starting at PS V3.0 we can also use the escape operator : --% ( will stop powershell resolving variables except cmd ones like %computername% ) |
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
$text –replace ‘\s+ ‘, ‘ ’ |
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
# SMAC - LM - 05/05/2015 | |
<# | |
.Synopsis | |
Recherche des dossiers dans outlook | |
Si un nom de dossier est passé en paramètre le script affichera son chemin d'accès, | |
Si aucun nom n'est fourni, le script liste tous les dossiers outlook | |
.Description | |
Utilisation de l'objet COM outlook afin de parcourir les dossiers. | |
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
Hi, | |
Please try below code: | |
$app = Get-WmiObject -Class Win32_Product | Where-Object { | |
$_.Name -match "Software Name" | |
} | |
$app.Uninstall() | |
Please use invoke-command above code to run them on the remote computer, in addition, the below article should be helpful: | |
Use PowerShell to Find and Uninstall Software | |
http://blogs.technet.com/b/heyscriptingguy/archive/2011/12/14/use-powershell-to-find-and-uninstall-software.aspx | |
wershell: Uninstall software on remote computer |
OlderNewer