Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
PS C:\PS ping> C:\PS ping\script.ps1
Произошла ошибка при вызове метода, так как [System.Object[]] не содержит метод с именем "Substring".
C:\PS ping\script.ps1:42 знак:27
+ $line = $data.Substring <<<< (0,47)
+ CategoryInfo : InvalidOperation: (Substring:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:51 знак:16
+ $f = $line[ <<<< $i].IndexOf("/")
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:52 знак:16
+ $l = $line[ <<<< $i].LastIndexOf("/")
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:53 знак:18
+ $ip += $line[ <<<< $i].Substring(0,$f)
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:54 знак:19
+ $capt += $line[ <<<< $i].Substring($f+1,$l-$f-1)
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Test-Connection : Не удается проверить аргумент для параметра "ComputerName". Аргумент пустой или имеет значение NULL. Укажите не пустой аргумент, не имеющий значение NULL, после чего повторите выполнение команды.
C:\PS ping\script.ps1:10 знак:41
+ if ((Test-Connection -Count 1 -computer <<<< $path_ip -quiet) -eq $True) {
+ CategoryInfo : InvalidData: (:) [Test-Connection], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.TestConnectionCommand
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:51 знак:16
+ $f = $line[ <<<< $i].IndexOf("/")
+ CategoryInfo : InvalidOperation: (1:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:52 знак:16
+ $l = $line[ <<<< $i].LastIndexOf("/")
+ CategoryInfo : InvalidOperation: (1:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:53 знак:18
+ $ip += $line[ <<<< $i].Substring(0,$f)
+ CategoryInfo : InvalidOperation: (1:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:54 знак:19
+ $capt += $line[ <<<< $i].Substring($f+1,$l-$f-1)
+ CategoryInfo : InvalidOperation: (1:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Test-Connection : Не удается проверить аргумент для параметра "ComputerName". Аргумент пустой или имеет значение NULL. Укажите не пустой аргумент, не имеющий значение NULL, после чего повторите выполнение команды.
C:\PS ping\script.ps1:10 знак:41
+ if ((Test-Connection -Count 1 -computer <<<< $path_ip -quiet) -eq $True) {
+ CategoryInfo : InvalidData: (:) [Test-Connection], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.TestConnectionCommand
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:51 знак:16
+ $f = $line[ <<<< $i].IndexOf("/")
+ CategoryInfo : InvalidOperation: (2:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:52 знак:16
+ $l = $line[ <<<< $i].LastIndexOf("/")
+ CategoryInfo : InvalidOperation: (2:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:53 знак:18
+ $ip += $line[ <<<< $i].Substring(0,$f)
+ CategoryInfo : InvalidOperation: (2:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Не удается индексировать в массив NULL.
C:\PS ping\script.ps1:54 знак:19
+ $capt += $line[ <<<< $i].Substring($f+1,$l-$f-1)
+ CategoryInfo : InvalidOperation: (2:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Test-Connection : Не удается проверить аргумент для параметра "ComputerName". Аргумент пустой или имеет значение NULL. Укажите не пустой аргумент, не имеющий значение NULL, после чего повторите выполнение команды.
C:\PS ping\script.ps1:10 знак:41
+ if ((Test-Connection -Count 1 -computer <<<< $path_ip -quiet) -eq $True) {
+ CategoryInfo : InvalidData: (:) [Test-Connection], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.TestConnectionCommand
Windows PowerShell
(C) Корпорация Майкрософт (Microsoft Corporation), 2016. Все права защищены.
PS > $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.3053
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3053
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\PS ping> .\script.ps1
Исключение при вызове "Speak" с "1" аргументами: "Обнаружена ошибка звукового устройства. - Error Code: 0x2"
C:\PS ping\script.ps1:15 знак:3
+ $voice.Speak("Ошибка! Хост " + $path_ip + ", недоступен!")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : AudioException
Не удается найти свойство "imageLocation" для данного объекта. Убедитесь, что оно существует и его можно задать.
C:\PS ping\script.ps1:11 знак:3
+ $PictureBox.imageLocation = $script_path + "\yes.png"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Исключение при вызове "Speak" с "1" аргументами: "Операция является недопустимой из-за текущего состояния объекта."
C:\PS ping\script.ps1:15 знак:3
+ $voice.Speak("Ошибка! Хост " + $path_ip + ", недоступен!")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Cancel
PS > $PSVersionTable
Name Value
---- -----
PSVersion 6.2.1
PSEdition Core
GitCommitId 6.2.1
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS > .\script.ps1
Add-Type : Cannot find path 'C:\PS ping\System.Windows.Forms.dll' because it does not exist.
At C:\PS ping\script.ps1:2 char:1
+ Add-Type -assembly System.Windows.Forms
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\PS ping\System.Windows.Forms.dll:String) [Add-Type], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.AddTypeCommand
Exception setting "Rate": "Object reference not set to an instance of an object."
At C:\PS ping\script.ps1:7 char:1
+ $voice.Rate = 5
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
New-Object : Cannot find type [System.Windows.Forms.Form]: verify that the assembly containing this type is loaded.
At C:\PS ping\script.ps1:34 char:16
+ $main_form = New-Object System.Windows.Forms.Form
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:35 char:1
+ $main_form.Text = 'Links up'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Width' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:36 char:1
+ $main_form.Width = 250
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Height' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:37 char:1
+ $main_form.Height = 250
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'AutoSize' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:38 char:1
+ $main_form.AutoSize = $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'TopMost' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:39 char:1
+ $main_form.TopMost = $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
New-Object : Cannot find type [System.Windows.Forms.Label]: verify that the assembly containing this type is loaded.
At C:\PS ping\script.ps1:59 char:35
+ ... ne -label ($label_obj = New-Object System.Windows.Forms.Label) -path_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
New-Object : Cannot find type [system.Windows.Forms.PictureBox]: verify that the assembly containing this type is loaded.
At C:\PS ping\script.ps1:60 char:45
+ ... ($PictureBox_obj = New-Object system.Windows.Forms.PictureBox) -path_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:62 char:2
+ $main_form.Controls.Add($labels[$i])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:63 char:2
+ $main_form.Controls.Add($PictureBoxs[$i])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
New-Object : Cannot find type [System.Windows.Forms.Label]: verify that the assembly containing this type is loaded.
At C:\PS ping\script.ps1:59 char:35
+ ... ne -label ($label_obj = New-Object System.Windows.Forms.Label) -path_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
New-Object : Cannot find type [system.Windows.Forms.PictureBox]: verify that the assembly containing this type is loaded.
At C:\PS ping\script.ps1:60 char:45
+ ... ($PictureBox_obj = New-Object system.Windows.Forms.PictureBox) -path_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:62 char:2
+ $main_form.Controls.Add($labels[$i])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:63 char:2
+ $main_form.Controls.Add($PictureBoxs[$i])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
New-Object : Cannot find type [System.Windows.Forms.Label]: verify that the assembly containing this type is loaded.
At C:\PS ping\script.ps1:59 char:35
+ ... ne -label ($label_obj = New-Object System.Windows.Forms.Label) -path_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
New-Object : Cannot find type [system.Windows.Forms.PictureBox]: verify that the assembly containing this type is loaded.
At C:\PS ping\script.ps1:60 char:45
+ ... ($PictureBox_obj = New-Object system.Windows.Forms.PictureBox) -path_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:62 char:2
+ $main_form.Controls.Add($labels[$i])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:63 char:2
+ $main_form.Controls.Add($PictureBoxs[$i])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
New-Object : Cannot find type [System.Windows.Forms.Label]: verify that the assembly containing this type is loaded.
At C:\PS ping\script.ps1:69 char:14
+ $Label0 = New-Object System.Windows.Forms.Label
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:70 char:1
+ $Label0.Text = Get-Date
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Location' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:71 char:1
+ $Label0.Location = New-Object System.Drawing.Point(80,180)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'AutoSize' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:72 char:1
+ $Label0.AutoSize = $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
New-Object : Cannot find type [System.Windows.Forms.Button]: verify that the assembly containing this type is loaded.
At C:\PS ping\script.ps1:74 char:14
+ $Button = New-Object System.Windows.Forms.Button
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
The property 'Location' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:75 char:1
+ $Button.Location = New-Object System.Drawing.Size(100,200)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Size' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:76 char:1
+ $Button.Size = New-Object System.Drawing.Size(80,30)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
At C:\PS ping\script.ps1:77 char:1
+ $Button.Text = "Reload"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:79 char:1
+ $Button.Add_Click({
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:89 char:1
+ $main_form.Controls.Add($Button)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:90 char:1
+ $main_form.Controls.Add($Label0)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\PS ping\script.ps1:92 char:1
+ $main_form.ShowDialog()
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Исключение при вызове «Speak» с «1» аргументами: «Обнаружена ошибка звукового устройства. — Error Code: 0x2»Первое логично, на серверах редко подразумевается наличие динамика.
C:\PS ping\script.ps1:15 знак:3
+ $voice.Speak(«Ошибка! Хост » + $path_ip + ", недоступен!")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId: AudioException
Add-Type: Cannot find path 'C:\PS ping\System.Windows.Forms.dll' because it does not exist.Странно.
At C:\PS ping\script.ps1:2 char:1
+ Add-Type -assembly System.Windows.Forms
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: ObjectNotFound: (C:\PS ping\System.Windows.Forms.dll:String) [Add-Type], ItemNotFoundException
+ FullyQualifiedErrorId: PathNotFound,Microsoft.PowerShell.Commands.AddTypeCommand
$script_path = "C:\Test\PS ping"Есть же $PSScriptRoot
#каринка в base64
base64IconString = "iVB...mCC"
$bitmap = New-Object System.Windows.Media.Imaging.BitmapImage
$bitmap.BeginInit()
$bitmap.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($base64IconString)
$bitmap.EndInit()
$bitmap.Freeze()
$form.Icon = $bitmap
if (Test-Connection $ComboBox.Text -Count 1 -Quiet) {
$Ping.content = "Ping ok"
$Ping.Background = "#FF3BE62A"
}
else {
$Ping.content = "Ping ERROR!"
$Ping.Background = "#FFE62A2A"
}
<?xml version="1.0" encoding="utf-8"?>
<Settings>
<Windows>
<WindowsTitle>Выберите компьютер</WindowsTitle>
<WindowsToolTip>Программа передает имя компьютера как параметр на запуск</WindowsToolTip>
<Lable>Выберите компьютер из списк или внесите свой:</Lable>
<ToolTip>Выберите компьютер из списк или внесите свой, для запуска остнастки</ToolTip>
<Button>Запустить остнаску</Button>
</Windows>
<Programm>
<RunnungString>c:\windows\system32\compmgmt.msc</RunnungString>
<ParametrString>/s /computer:$parametr</ParametrString>
</Programm>
<list>
<name>Server.Domain.name</name>
<name>OtherServer.Domain.name</name>
</list>
</Settings>
$myDir = [System.AppDomain]::CurrentDomain.BaseDirectory.TrimEnd('\')
if ($myDir -eq $PSHOME.TrimEnd('\')) { $myDir = $PSScriptRoot}
If (!(Test-Path $MyDir\Settings.xml)) {write-host 'Setting file ' $MyDir\Settings.xml ' not found..' -ForegroundColor Red ; exit}
[xml]$ConfigFile = Get-Content $ConfigXML
$form.Title = $ConfigFile.Settings.Windows.WindowsTitle
$form.ToolTip = $ConfigFile.Settings.Windows.WindowsToolTip
$ComboBox.ToolTip = $ConfigFile.Settings.windows.ToolTip
$button1.Content = $ConfigFile.Settings.windows.Button
$RunnungProgrammString = $ConfigFile.Settings.Programm.RunnungString
$RunnungParametrString = $ConfigFile.Settings.Programm.ParametrString
#Добвление в цикле множества элементов
[array]$ComboBoxItems = $ConfigFile.Settings.list.name
$ComboBoxItems| % {
$ComboBox.Items.Add($_)| out-null
}
$ConfigFile.Settings.list.AppendChild($newSettings)
$ConfigFile.Save($ConfigXML)
Есть уже готовый софт для таких целей PingInfoView
Мониторинг доступности хостов на Powershell