Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung Nächste Überarbeitung Beide Seiten der Revision | ||
programmierung:powershell [2012-06-11 15:03] stefan |
programmierung:powershell [2012-07-10 11:15] stefan |
||
---|---|---|---|
Zeile 4: | Zeile 4: | ||
* check if an error occured (e.g. after cmdlet with suppressed output): ''if (!$?)'' | * check if an error occured (e.g. after cmdlet with suppressed output): ''if (!$?)'' | ||
* ''copy-item'' throws an ''UnauthorizedAccessException'': use parameter ''-force'' | * ''copy-item'' throws an ''UnauthorizedAccessException'': use parameter ''-force'' | ||
+ | * RegEx: <code posh>$m = [regex]::matches("test", "([a-z]+)"); | ||
+ | if ($m[0].Success) | ||
+ | { | ||
+ | $str = $m[0].Groups[1].ToString(); | ||
+ | }</code> | ||
+ | * get name and path of the currently running script: <code posh>$scriptName = $MyInvocation.MyCommand.Name; | ||
+ | $scriptPath = split-path $MyInvocation.MyCommand.Path;</code> |