Skip to content

Instantly share code, notes, and snippets.

View Dan1el42's full-sized avatar

Daniel Krebs Dan1el42

View GitHub Profile
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
$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) {
$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) {
$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')}
$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
}
@Dan1el42
Dan1el42 / gist:ddd05775467c9ec16cfe
Created February 16, 2016 17:21
MS-RDG-Device-Redirection - Get decimal value for configuration
# 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
#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"
$Servers = @(
'server1.example.com'
'server2.example.com'
'server1000.example.com'
)
$ScriptBlock = {
$x = 10
"start first command with $x"
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)
$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
}
}