Push
This commit is contained in:
38
Sharepoint/gui/Re-Link/reLink.ps1
Normal file
38
Sharepoint/gui/Re-Link/reLink.ps1
Normal file
@ -0,0 +1,38 @@
|
||||
$oldPrefix = "\\Srv75008s\juridique"
|
||||
$newPrefix = "%userprofile%\Skornik\Dossiers utilisateurs - Documents\Juridique"
|
||||
|
||||
#$oldPrefix = "\\srv75008s\Commun"
|
||||
#$newPrefix = "%userprofile%\Skornik\Commun - Documents"
|
||||
|
||||
|
||||
$searchPath = "Z:\juridique"
|
||||
|
||||
$dryRun = $FALSE
|
||||
|
||||
$shell = new-object -com wscript.shell
|
||||
|
||||
if ( $dryRun ) {
|
||||
write-host "Dry run..." -foregroundcolor green -backgroundcolor black
|
||||
} else {
|
||||
write-host "Warning : Real run" -foregroundcolor red -backgroundcolor black
|
||||
}
|
||||
|
||||
dir $searchPath -filter *.lnk -recurse | foreach {
|
||||
$lnk = $shell.createShortcut( $_.fullname )
|
||||
$oldPath= $lnk.targetPath
|
||||
|
||||
$lnkRegex = "^" + [regex]::escape( $oldPrefix )
|
||||
|
||||
if ( $oldPath -match $lnkRegex ) {
|
||||
$newPath = $oldPath -replace $lnkRegex, $newPrefix
|
||||
|
||||
write-host "Found: " + $_.fullname -foregroundcolor yellow -backgroundcolor black
|
||||
write-host " Replace: " + $oldPath
|
||||
write-host " With: " + $newPath
|
||||
|
||||
if ( !$dryRun ) {
|
||||
$lnk.targetPath = $newPath
|
||||
$lnk.Save()
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user