This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Import-Csv -Path '.\Input.csv' | | |
| Select-Object -Property MACHINENAME, @{Name='OSVERSION'; Expression={ Get-WmiObject -Class Win32_OperatingSystem -Property Caption -ComputerName $_.MACHINENAME -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Caption }} | | |
| Export-Csv -Path '.\Output.csv' -NoTypeInformation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Desktops = get-content c:\temp\desktoplist.txt | |
| foreach ($Desktop in $Desktops) { | |
| switch -wildcard ($Desktop) { | |
| 'UK*'{$servers = @('UKSite1.com', 'UKSite2.com')} | |
| 'US*'{$servers = @('USSite1.com')} | |
| 'SG*'{$servers = @('SGSite1.com')} | |
| } | |
| $DesktopDetail = foreach ($server in $servers) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Desktops = get-content c:\temp\desktoplist.txt | |
| foreach ($Desktop in $Desktops) { | |
| switch -wildcard ($Desktop) { | |
| 'UK*'{$servers = @('UKSite1.com', 'UKSite2.com')} | |
| 'US*'{$servers = @('USSite1.com')} | |
| 'SG*'{$servers = @('SGSite1.com')} | |
| } | |
| $DesktopDetail = foreach ($server in $servers) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Desktops = Get-Content -Path c:\temp\desktoplist.txt | |
| # The ArrayList class allows the array to expand dynamically | |
| $DesktopDetails = New-Object -TypeName System.Collections.ArrayList | |
| foreach ($Desktop in $Desktops) { | |
| switch -wildcard ($Desktop) { | |
| 'UK*'{$servers = @('UKSite1.com', 'UKSite2.com')} | |
| 'US*'{$servers = @('USSite1.com')} | |
| 'SG*'{$servers = @('SGSite1.com')} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $MpioRegisteredDSM = Get-CimInstance -Namespace ROOT/WMI -Class MPIO_REGISTERED_DSM | |
| $MpioRegisteredDSM.DsmParameters | Where-Object DsmName -eq 'Microsoft DSM' | | |
| ForEach-Object { | |
| $PSItem.DsmCounters.PathVerifyEnabled = 1 | |
| Get-CimInstance -Namespace ROOT/WMI -ClassName MPIO_WMI_METHODS | | |
| Invoke-CimMethod -MethodName SetDSMCounters -Arguments @{ | |
| DsmContext = $PSItem.DsmContext | |
| DsmCounters = $PSItem.DsmCounters | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # MS-RDG-Device-Redirection | |
| # https://msdn.microsoft.com/en-us/library/cc243459.aspx | |
| $ByteArray = [System.Array]::CreateInstance([byte], 32) | |
| $ByteArray.Set(0, 1) # Drive redirection disabled | |
| $ByteArray.Set(1, 1) # Printers redirection disabled | |
| $ByteArray.Set(2, 1) # Serial ports redirection disabled | |
| $ByteArray.Set(3, 1) # Clipboard redirection disabled | |
| $ByteArray.Set(4, 0) # Plug and play devices redirection enabled | |
| $ByteArray.Set(29, 0) # Device redirection is controlled by bits 0..4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Variable setup | |
| $DateTime = Get-Date -Format "yyyyMMdd-hhmmss" | |
| $SvnAdminExecutablePath = "C:\Program Files\VisualSVN Server\bin\svnadmin.exe" | |
| $SvnAdminSubcommand = "dump" | |
| $RepositoriesRootPath = "D:\Repositories" | |
| $RepositoryName = "Admin" | |
| $RepositoryPath = Join-Path -Path $RepositoriesRootPath -ChildPath $RepositoryName | |
| $BackupRootPath = "\\c2sd2643t\SVN-BU" | |
| $BackupFilePath = Join-Path -Path $BackupRootPath -ChildPath "${RepositoryName}_${DateTime}.svndump" | |
| $BackupMessagesFilePath = Join-Path -Path $BackupRootPath -ChildPath "${RepositoryName}_${DateTime}.txt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Servers = @( | |
| 'server1.example.com' | |
| 'server2.example.com' | |
| 'server1000.example.com' | |
| ) | |
| $ScriptBlock = { | |
| $x = 10 | |
| "start first command with $x" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Import-Module BitsTransfer | |
| $Uri = 'http://download.nai.com/products/licensed/superdat/nai/Brazilian' | |
| $DestinationPath = 'D:\Temp' | |
| $Response = Invoke-WebRequest -UseBasicParsing -Uri $Uri | |
| if ($Response.StatusCode -eq 200) { | |
| $Matches = [regex]::Matches($Response.RawContent, '(\d+xdat\.exe)"') | |
| if ($Matches.Count -ge 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $servers | ForEach-Object { | |
| $PSDriveName = '{0}ServerRoot' -f $_ | |
| New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root \\$_\C$ -Credential $creds | |
| try { | |
| Copy-Item -Path '.\cl21163_Groups.txt' -Destination "${PSDriveName}:\" | |
| } finally { | |
| Remove-PSDrive -Name $PSDriveName -Force | |
| } | |
| } |