datentraeger

geistige Umweltverschmutzung

Powershell Try-Catch, Messageboxen, Schleifen

January 24, 2011 Win

Try-Catch kann ähnlich zu VB verwendet werden…

function tuirgendwas   {
  try {
    irgendeine Anweisung
  } catch {
    [system.exception]
    write-host "Fehler aufgetreten"
  } finally {
    Return # Funktion beenden
  }
}

und Messageboxen kann man beispielsweise folgendermassen erzeugen (also das Zeilenumbruch-Zeichen ist gewöhnungsbedürtig (`):

[System.Windows.Forms.MessageBox]::Show("Hallo Welt!", "Info", `
[Windows.Forms.MessageBoxButtons]::OK ,[Windows.Forms.MessageBoxIcon]::Information)

Do While

$a=1
do {$a; $a++}
while ($a -lt 10)

Do Until

$a=1
do {$a; $a++}
until ($a -gt 10)

for

for {$a=1; $a -le 10; $a++}
{$a}

mehrere Bedingungen bei if

if ( $arg1 -le "" -OR $arg2 -le "" )

Gmail und forwarder zu sich selbst

LV Resize

Search
Posts
  • Overleaf
  • wir haben 300’000 !!
  • ZNAP Wallet
  • wtf m$ S3150 ?!?
  • systemd failed status entfernen
Archives
Categories
Tags
3D-Printing Android Apple Arch Backup BBOS/QNX cli Container Database Debian/GNU Linux Docker foo.li FSFE git Gnome Gnusocial Groupware irc IT Java LaTeX lvm Mail Mobile Movies Multimedia Music Nonsense Office Packaging PHP Puppet Redmine SQL Think-About Uncategorized Vaping vim Virtualisierung Web Win WTF www-links X11 XMPP
Meta
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Blogroll
  • Datentraeger Pics
  • foo.li systeme + software
  • GnuSocial.li
Proudly powered by WordPress | Theme: Doo by ThemeVS.