Powershell

https://docs.microsoft.com/en-us/powershell/scripting/samples/multiple-selection-list-boxes?view=powershell-6

=========================

list box controls that allow multiple selections

===========================================
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$form = New-Object System.Windows.Forms.Form
$form.Text = 'Data Entry Form'
$form.Size = New-Object System.Drawing.Size(300,200)
$form.StartPosition = 'CenterScreen'

$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Point(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = 'OK'
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $OKButton
$form.Controls.Add($OKButton)

$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Point(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = 'Cancel'
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CancelButton
$form.Controls.Add($CancelButton)

$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please make a selection from the list below:'
$form.Controls.Add($label)

$listBox = New-Object System.Windows.Forms.Listbox
$listBox.Location = New-Object System.Drawing.Point(10,40)
$listBox.Size = New-Object System.Drawing.Size(260,20)

$listBox.SelectionMode = 'MultiExtended'

[void] $listBox.Items.Add('Item 1')
[void] $listBox.Items.Add('Item 2')
[void] $listBox.Items.Add('Item 3')
[void] $listBox.Items.Add('Item 4')
[void] $listBox.Items.Add('Item 5')

$listBox.Height = 70
$form.Controls.Add($listBox)
$form.Topmost = $true

$result = $form.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
    $x = $listBox.SelectedItems
    $x
}

============================

graphical date-picker control

===============================================


Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $form = New-Object Windows.Forms.Form $form.Text = 'Select a Date' $form.Size = New-Object Drawing.Size @(243,230) $form.StartPosition = 'CenterScreen' $calendar = New-Object System.Windows.Forms.MonthCalendar $calendar.ShowTodayCircle = $false $calendar.MaxSelectionCount = 1 $form.Controls.Add($calendar) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Point(38,165) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = 'OK' $OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK $form.AcceptButton = $OKButton $form.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Point(113,165) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = 'Cancel' $CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $form.CancelButton = $CancelButton $form.Controls.Add($CancelButton) $form.Topmost = $true $result = $form.ShowDialog() if ($result -eq [System.Windows.Forms.DialogResult]::OK) { $date = $calendar.SelectionStart Write-Host "Date selected: $($date.ToShortDateString())" }


============================================================
INPUT BOX
==================================================

Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $form = New-Object System.Windows.Forms.Form $form.Text = 'Data Entry Form' $form.Size = New-Object System.Drawing.Size(300,200) $form.StartPosition = 'CenterScreen' $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Point(75,120) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = 'OK' $OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK $form.AcceptButton = $OKButton $form.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Point(150,120) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = 'Cancel' $CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $form.CancelButton = $CancelButton $form.Controls.Add($CancelButton) $label = New-Object System.Windows.Forms.Label $label.Location = New-Object System.Drawing.Point(10,20) $label.Size = New-Object System.Drawing.Size(280,20) $label.Text = 'Please enter the information in the space below:' $form.Controls.Add($label) $textBox = New-Object System.Windows.Forms.TextBox $textBox.Location = New-Object System.Drawing.Point(10,40) $textBox.Size = New-Object System.Drawing.Size(260,20) $form.Controls.Add($textBox) $form.Topmost = $true $form.Add_Shown({$textBox.Select()}) $result = $form.ShowDialog() if ($result -eq [System.Windows.Forms.DialogResult]::OK) { $x = $textBox.Text $x }

===========================

Locking a Computer

rundll32.exe user32.dll,LockWorkStation

Logging Off the Current Session

logoff /?
shutdown.exe -l

(Get-WmiObject -Class Win32_OperatingSystem -ComputerName .).Win32Shutdown(0)

Shutting Down or Restarting a Computer

tsshutdn.exe /? or shutdown.exe /?.
Stop-Computer
Restart-Computer
Restart-Computer -Force

===================================================

Desktop Settings

Get-CimInstance -ClassName Win32_Desktop -ComputerName .

Get-CimInstance -ClassName Win32_Desktop -ComputerName . | Select-Object -ExcludeProperty "CIM*"
Get-CimInstance -ClassName Win32_BIOS -ComputerName .
Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName . | Select-Object -Property SystemType
Get-CimInstance -ClassName Win32_ComputerSystem

Get-CimInstance -ClassName Win32_QuickFixEngineering -ComputerName .
Get-CimInstance -ClassName Win32_QuickFixEngineering -ComputerName . -Property HotFixID
Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName . | Select-Object -Property BuildNumber,BuildType,OSType,ServicePackMajorVersion,ServicePackMinorVersion

Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName . | Select-Object -Property NumberOfLicensedUsers,NumberOfUsers,RegisteredUser

================================================

list box control, and select items from it



Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$form = New-Object System.Windows.Forms.Form
$form.Text = 'Select a Computer'
$form.Size = New-Object System.Drawing.Size(300,200)
$form.StartPosition = 'CenterScreen'

$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Point(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = 'OK'
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $OKButton
$form.Controls.Add($OKButton)

$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Point(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = 'Cancel'
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CancelButton
$form.Controls.Add($CancelButton)

$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please select a computer:'
$form.Controls.Add($label)

$listBox = New-Object System.Windows.Forms.ListBox
$listBox.Location = New-Object System.Drawing.Point(10,40)
$listBox.Size = New-Object System.Drawing.Size(260,20)
$listBox.Height = 80

[void] $listBox.Items.Add('atl-dc-001')
[void] $listBox.Items.Add('atl-dc-002')
[void] $listBox.Items.Add('atl-dc-003')
[void] $listBox.Items.Add('atl-dc-004')
[void] $listBox.Items.Add('atl-dc-005')
[void] $listBox.Items.Add('atl-dc-006')
[void] $listBox.Items.Add('atl-dc-007')

$form.Controls.Add($listBox)

$form.Topmost = $true

$result = $form.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
    $x = $listBox.SelectedItem
    $x
}

=====================
PS> Get-Location
Push-Location -Path "Local Settings"
Push-Location -Path Temp

PS> Pop-Location PS> Get-Location
PS> Pop-Location -PassThru
Set-Location \\FS01\Public
Push-Location \\FS01\Public
PS> Stop-Process -Name Idle
PS> Stop-Process -Name t*,e* -Confirm

Get-Process | Where-Object -FilterScript {$_.Responding -eq $false} | Stop-Process
Get-Process -Name BadApp | Where-Object -FilterScript {$_.SessionId -neq 0} | Stop-Process
Invoke-Command -ComputerName Server01 {Stop-Process Powershell}

PS> Get-Process -Name powershell | Where-Object -FilterScript {$_.Id -ne $PID} | Stop-Process -PassThru
PS> Get-Service -Name se*

Get-Service -DisplayName se*
Get-Service -DisplayName ServiceLayer,Server
Get-Service -Name LanmanWorkstation -RequiredServices
Get-Service -Name LanmanWorkstation -DependentServices
Get-Service -Name * | Where-Object {$_.RequiredServices -or $_.DependentServices} | Format-Table -Property Status, Name, RequiredServices, DependentServices -auto

Stop-Service -Name spooler
Start-Service -Name spooler
Suspend-Service -Name spooler
Restart-Service -Name spooler
Get-Service | Where-Object -FilterScript {$_.CanStop} | Restart-Service

Invoke-Command -ComputerName Server01 {Restart-Service Spooler}

========================================================
Get-PSDrive

Get-Command -Name Get-PSDrive -Syntax
Get-PSDrive -PSProvider FileSystem
Get-PSDrive -PSProvider Registry
Set-Location HKLM:\SOFTWARE
Push-Location .\Microsoft
Get-Location
Set-Location cvkey: -PassThru
Remove-PSDrive -Name Office
Remove-PSDrive -Name cvkey
PS> cd office: PS Office:\> remove-psdrive -name office

===============================================
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true -ComputerName . | Format-Table -Property IPAddress

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true -ComputerName .

Get-WmiObject -Class Win32_PingStatus -Filter "Address='127.0.0.1'" -ComputerName .

'127.0.0.1','localhost','research.microsoft.com' | ForEach-Object -Process {Get-WmiObject -Class Win32_PingStatus -Filter ("Address='" + $_ + "'") -ComputerName .} | Select-Object -Property Address,ResponseTime,StatusCode

1..254| ForEach-Object -Process {Get-WmiObject -Class Win32_PingStatus -Filter ("Address='192.168.1." + $_ + "'") -ComputerName .} | Select-Object -Property Address,ResponseTime,StatusCode

$ips = 1..254 | ForEach-Object -Process {'192.168.1.' + $_}

Get-WmiObject -Class Win32_NetworkAdapter -ComputerName .
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true -ComputerName . | ForEach-Object -Process { $_. SetDNSDomain('fabrikam.com') }
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "DHCPEnabled=$true" -ComputerName .

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "DHCPEnabled=$true" -ComputerName . | Format-Table -Property DHCP*

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true -ComputerName . | ForEach-Object -Process {$_.EnableDHCP()}

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=$true and DHCPEnabled=$true" -ComputerName . | Where-Object -FilterScript {$_.DHCPServer -contains '192.168.1.254'} | ForEach-Object -Process {$_.ReleaseDHCPLease()}

Get-WmiObject -List | Where-Object -FilterScript {$_.Name -eq 'Win32_NetworkAdapterConfiguration'}
( Get-WmiObject -List | Where-Object -FilterScript {$_.Name -eq 'Win32_NetworkAdapterConfiguration'} ).ReleaseDHCPLeaseAll()

(Get-WmiObject -List -ComputerName . | Where-Object -FilterScript {$_.Name -eq 'Win32_Share'}).Create('C:\temp','TempShare',0,25,'test share of the temp folder')


=======================================

COPYDISP.BAT
S++

@echo ON
rem S+ Server b
CALL DISPNODE_SRX 192.168.3.22 
rem S+ Hist A
CALL DISPNODE_SRX 192.168.3.23 
rem S+ Hist b
CALL DISPNODE_SRX 192.168.3.24 
rem S+ client 01 -0101-CWO-M8981
CALL DISPNODE_SRX 192.168.3.31 
rem S+ client 02 -0101-CWO-M8982
CALL DISPNODE_SRX 192.168.3.32 
rem S+ client 03 - 0101-CWO-P8981
CALL DISPNODE_SRX 192.168.3.33 
rem S+ client 04 - 0101-CWO-S8981
CALL DISPNODE_SRX 192.168.3.34 
rem S+ client 05 - 0101-CWO-S8991
CALL DISPNODE_SRX 192.168.3.35 
rem S+ client 06 - 0101-CWO-S8992
CALL DISPNODE_SRX 192.168.3.36 
rem S+ client 07 - 0101-CWO-S8993
CALL DISPNODE_SRX 192.168.3.37 
rem S+ client 08 - 0101-CWO-D8981
CALL DISPNODE_SRX 192.168.3.38 
rem S+ client 09 - 0101-CWO-W8981
CALL DISPNODE_SRX 192.168.3.39 
rem S+ client 10 - 0101-CWO-W8982
CALL DISPNODE_SRX 192.168.3.40 
rem S+ client 11 - 0101-CWO-C8981
CALL DISPNODE_SRX 192.168.3.41 
rem S+ client 12 - 0101-CWO-U8981
CALL DISPNODE_SRX 192.168.3.42 

REM
REM Done updating displays to all PCs
REM
pause

==========================================================
DISPNODE_SRX.BAT

robocopy "\\192.168.3.21\c$\ProgramData\ABB Symphony Plus\Operations\SV1.0\display\bin" "\\%1\c$\ProgramData\ABB Symphony Plus\Operations\SV1.0\display\bin" /xo /r:2 

robocopy "\\192.168.3.21\c$\ProgramData\ABB Symphony Plus\Operations\SV1.0\display\binSym" "\\%1\c$\ProgramData\ABB Symphony Plus\Operations\SV1.0\display\binsym" /xo /r:2



Comments

Popular posts from this blog

WWare_Scripts

php Programming

practica Html 4