full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Evacuate-Host.ps1
Evacuate-Host.ps1
[cmdletbinding()] Param ( $vmhost, [switch]$whatif = $true, $vmotionlimit = 5, $vcenter = "vcenter" ) function WriteHost($target="Startup",$message,$color="White") { Write-Host "$($target): $($message)" -ForegroundColor $color; if($color -eq "Red") { Exit } } function vMotionVM($vms,...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/MoveUplinkMgmt-VSStoDVS.ps1
MoveUplinkMgmt-VSStoDVS.ps1
[cmdletbinding()] Param ( [Parameter(Mandatory=$true)]$vcenter, [Parameter(Mandatory=$true)]$server ) function WriteHost($message,$color="White") { Write-Host "$($server): $($message)" -ForegroundColor $color; if($color -eq "Red") { Exit } } try { Connect-VIServer $vcenter -ErrorAction Stop | Out-Null...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Copy-DVStoVSS.ps1
Copy-DVStoVSS.ps1
[cmdletbinding()] Param ( [Parameter(Mandatory=$true)]$vcenter, [Parameter(Mandatory=$true)]$server ) function WriteHost($message,$color="White") { Write-Host "$($server): $($message)" -ForegroundColor $color; if($color -eq "Red") { Exit } } try { Connect-VIServer $vcenter -ErrorAction Stop | Out-Null...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Set-MemoryReservations.ps1
Set-MemoryReservations.ps1
# Examples: # Remove MemoryReservationLockToMax for all servers in the my-cluster cluster # .\Set-MemoryReservations.ps1 -cluster my-cluster -remove # # Add MemoryReservationLockToMax for all servers in the my-cluster cluster # .\Set-MemoryReservations.ps1 -cluster jax-devqc -add # # Add MemoryReservationLockToM...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Enable-SNMP-ESXi.ps1
Enable-SNMP-ESXi.ps1
[cmdletbinding()] Param ( $server, $domain ) cvi | Out-Null if($server) { $vmhosts = Get-VMHost $server } elseif($domain) { $vmhosts = Get-VMHost | ?{$_.Name -like "*$domain" } } else { $vmhosts = Get-VMHost | ?{$_.Name -like "*domain.local"} | sort name } $cred = Get-Credential foreach($v in $vmhos...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Set-VMNIC.ps1
Set-VMNIC.ps1
[cmdletbinding()] Param ( $csv, [switch]$cred ) function GetCSV($csvfile) { if(!(Test-Path $csvfile)) { Write-Verbose "$($csvfile) does not exist. Try again." } elseif(!($csvfile.substring($csvfile.LastIndexOf(".")+1) -eq "csv")) { Write-Verbose "$($csvfile) is not a CSV. T...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Parse-VMwareLog.ps1
Parse-VMwareLog.ps1
[cmdletbinding()] Param ( $file, $readcount = 100 ) #Read a log file and figure out #Number of unique instances of a message $logbatches = Get-Content $file -ReadCount $readcount $messages = @() foreach($batch in $logbatches) { $i++ Write-Progress -Activity "Parsing log batch $i" -Statu...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Get-MemoryReservations.ps1
Get-MemoryReservations.ps1
[cmdletbinding()] Param ( [Parameter(Mandatory=$true)] $server ) $results = @() $status = Connect-VIServer wh-vc01.domain.local $vms = Get-VMHost $server | Get-VM foreach($vm in $vms) { $data = New-Object PSObject -Property @{ "Name" = $vm.Name "MemoryReservationLockToMax" = $...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Balance-Cluster-old.ps1
Balance-Cluster-old.ps1
[cmdletbinding()] Param ( $clusters = @("MyCluster"), $exclusions = "(-WTFLOL.*)", $vmotionlimit = 5, [switch]$whatif = $true, $MaintenanceMode ) function GetClusterTypes($c) { $all = @() if(!$MaintenanceMode) { $vms = get-cluster $c | Get-VM | sort name } else { $vms = get-...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Set-ResourcePoolShares.ps1
Set-ResourcePoolShares.ps1
cvi | Out-Null #Define the amount of CPU shares to recommend per vCPU $dev_shares = 1000 $qc_shares = 1500 $perf_shares = 2000 $pools = Get-Cluster CLUSTER | Get-ResourcePool | ?{$_.Name -like "DEV-*" -or $_.Name -like "QC-*"} | sort Name foreach($pool in $pools) { $processors = $pool | Get-VM | Measure-...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Export-All-DVS.ps1
Export-All-DVS.ps1
[cmdletbinding()] Param ( #[Parameter(Mandatory=$true)]$vcenter ) #Get-Cluster $Cluster | Get-VMHost | Get-VDSwitch | Get-VDPortGroup | ?{$_.VlanConfiguration.VlanType -ne "Trunk"} | #Select Name,NumPorts,VDSwitch,@{N="Vlan";E={$_.VlanConfiguration.VlanId}} | Export-CSV $Export -UseCulture -NoTypeInformatio...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Import-All-DVS.ps1
Import-All-DVS.ps1
[cmdletbinding()] Param ( [Parameter(Mandatory=$true)]$vcenter ) function WriteHost($message,$color="White") { Write-Host "$($message)" -ForegroundColor $color; if($color -eq "Red") { Exit } } try { Connect-VIServer $vcenter -ErrorAction Stop | Out-Null } catch { WriteHost "Failed to connect to $vcenter" ...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Add-PDrive.ps1
Add-PDrive.ps1
[cmdletbinding()] Param ( [alias("cn")] $computername="localhost" ) Connect-VIServer my-vcenter.domain.local | Out-Null foreach($computer in $computername) { $vm = $null try { $vm = get-vm $computer -ea "STOP"} catch { Write-Host "$($computer): No VM found" } if($vm) { $pd...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Get-DVSUplinks.ps1
Get-DVSUplinks.ps1
[cmdletbinding()] Param ( [Parameter(Mandatory=$true)]$vcenter ) function WriteHost($message,$color="White") { Write-Host "$($server): $($message)" -ForegroundColor $color; if($color -eq "Red") { Exit } } try { Connect-VIServer $vcenter -ErrorAction Stop | Out-Null } catch { WriteHost "Failed to connect t...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/MoveVM-VSStoDVS.ps1
MoveVM-VSStoDVS.ps1
[cmdletbinding()] Param ( [Parameter(Mandatory=$true)]$vcenter, [Parameter(Mandatory=$true)]$server ) function WriteHost($message,$color="White") { Write-Host "$($server): $($message)" -ForegroundColor $color; if($color -eq "Red") { Exit } } try { Connect-VIServer $vcenter -ErrorAction Stop | Out-Null...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Check-PhysicalOrVM.ps1
Check-PhysicalOrVM.ps1
[cmdletbinding()] Param ( [alias("s")] $server, $csv ) function GetCSV($csvfile) { if(!(Test-Path $csvfile)) { Write-Verbose "$($csvfile) does not exist. Try again." } elseif(!($csvfile.substring($csvfile.LastIndexOf(".")+1) -eq "csv")) { Write-Verbose "$($csvfile) is ...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Enable-SSH.ps1
Enable-SSH.ps1
$vmhosts = get-content hosts_ord.txt foreach($vmhost in $vmhosts) { Write-Host "Working on $vmhost" Get-VMHost $vmhost | Get-VMHostService | Where {$_.Key –eq “TSM-SSH”} | Start-VMHostService }
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Get-SyncTimeWithHost.ps1
Get-SyncTimeWithHost.ps1
[cmdletbinding()] Param ( $servers = "server", [switch]$all = $false ) function writeToObj($server,$synctime) { return New-Object PSObject -Property @{ Server = $server SyncTimeWithHost = $synctime } } function getAllViews() { try { Write-Host "Querying vCenter for al...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Set-SyncTimeWithHost.ps1
Set-SyncTimeWithHost.ps1
[cmdletbinding()] Param ( $servers, [switch]$enable = $False ) function getAllViews() { try { Write-Host "Querying vCenter for all views"; $VMViews = Get-View -ViewType VirtualMachine | Sort Name } catch { Write-Host "Failed to retreive data from vCenter. Are you connected?"; Exit } return...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/Get-NumCPU.ps1
Get-NumCPU.ps1
cvi | Out-Null function writeToObj($server,$hostcpu,$ratio,$allocatedcpu) { $obj= New-Object PSObject -Property @{ Host = $server HostCPUs = $hostcpu AllocatedCPUs = $allocatedcpu Ratio = $ratio } return $obj } $servers = Get-Cluster | Get-VMHost $allobj = ...
PowerShellCorpus/Github/abix-_powershell-practical/vmware/MoveUplinkMgmt-DVStoVSS.ps1
MoveUplinkMgmt-DVStoVSS.ps1
[cmdletbinding()] Param ( [Parameter(Mandatory=$true)]$vcenter, [Parameter(Mandatory=$true)]$server ) function WriteHost($message,$color="White") { Write-Host "$($server): $($message)" -ForegroundColor $color; if($color -eq "Red") { Exit } } try { Connect-VIServer $vcenter -ErrorAction Stop | Out-Null...
PowerShellCorpus/Github/abix-_powershell-practical/active-directory/Get-ADUserProperty.ps1
Get-ADUserProperty.ps1
[cmdletbinding()] Param ( $searchbase = "OU=Corporate,DC=domain,DC=wh", $dc = "my-dc.domain.local", $property = "msDS-SourceObjectDN" ) Import-Module ActiveDirectory Write-Host "Domain Controller:`t$dc" Write-Host "Search Base:`t`t$searchbase" Write-Host "Property:`t`t$property" $users = Get-ADU...
PowerShellCorpus/Github/abix-_powershell-practical/active-directory/Validate-DNS_AD.ps1
Validate-DNS_AD.ps1
[cmdletbinding()] Param ( [alias("s")] [Parameter(Mandatory=$true)] $dc, [Parameter(Mandatory=$true)] $domain ) Import-Module activedirectory function GetStaticARecords($server, $domain) { return Get-WmiObject -Class MicrosoftDNS_AType -NameSpace Root\MicrosoftDNS -ComputerName $s...
PowerShellCorpus/Github/abix-_powershell-practical/active-directory/Get-ComputerName_DN.ps1
Get-ComputerName_DN.ps1
[cmdletbinding()] Param ( $server ) function writeToObj($ip,$dn="N/A",$cardholder="N/A",$cn="N/A") { $obj= New-Object PSObject -Property @{ IP = $ip ComputerName = $cn DN = $dn Cardholder = $cardholder } return $obj } function getComputerName($ip){ W...
PowerShellCorpus/Github/abix-_powershell-practical/active-directory/Add-SecondaryZone.ps1
Add-SecondaryZone.ps1
[cmdletbinding()] Param ( $server, $zone, $master, $secondary ) foreach($srv in $server) { Write-Host "$($srv): Adding $zone..." dnscmd $srv /zoneadd $zone /secondary $master $secondary }
PowerShellCorpus/Github/abix-_powershell-practical/active-directory/Set-ADUserProperty.ps1
Set-ADUserProperty.ps1
[cmdletbinding()] Param ( [Parameter( Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true) ]$users, $searchbase = "OU=Corporate,DC=domain,DC=wh", $dc = "my-dc.domain.local", [Parameter(Mandatory=$true)][string]$prope...
PowerShellCorpus/Github/abix-_powershell-practical/active-directory/Fix-DNSZones.ps1
Fix-DNSZones.ps1
[cmdletbinding()] Param ( [Parameter(Mandatory=$true)]$domain, [Parameter(Mandatory=$true)]$ref_dc, $target_dc ) filter set-type { param([hashtable]$type_hash) foreach ($key in $($type_hash.keys)){ $_.$key = $($_.$key -as $type_hash[$key]) } $_ } $dcs = Import-Csv "$...
PowerShellCorpus/Github/abix-_powershell-practical/active-directory/Check-LockedAccounts.ps1
Check-LockedAccounts.ps1
Import-Module ActiveDirectory function EmailResults($computername,$queuename,$messagecount) { $global:smtpserver = "smtp.domain.local" $msg = new-object Net.Mail.MailMessage $smtp = new-object Net.Mail.SmtpClient($global:smtpserver) $msg.From = "msmq_monitor@domain.local" $msg.To.Add("Notify...
PowerShellCorpus/Github/abix-_powershell-practical/active-directory/Determine-OU.ps1
Determine-OU.ps1
[cmdletbinding()] Param ( $server ) function writeToObj($computername,$dn="N/A",$cardholder="N/A") { $obj= New-Object PSObject -Property @{ ComputerName = $computername DN = $dn Cardholder = $cardholder } return $obj } $computers = Get-ADComputer -filter * -search...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-OldFilesSize.ps1
Get-OldFilesSize.ps1
[cmdletbinding()] Param ( $scandir="c:\windows" ) Write-Host "Finding files in $scandir that have not been modified recently." $allfiles = get-childitem "$scandir" -recurse | where-object {$_.mode -notmatch "d"} | select fullname,lastwritetime,length $days = "60","90","180","365","547","730","912","1095...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Check-IIS.ps1
Check-IIS.ps1
[cmdletbinding()] Param ( [Parameter(ParameterSetName="Servers",Mandatory=$true)]$servers, [Parameter(ParameterSetName="MyPlatform")]$datacenter, [Parameter(ParameterSetName="MyPlatform")]$stack, [Parameter(ParameterSetName="MyPlatform")]$role, [Parameter(ParameterSetName="Servers",Mandatory=$...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Fix-KasperskyAuto.ps1
Fix-KasperskyAuto.ps1
[cmdletbinding()] Param ( [alias("s")] [Parameter(Mandatory=$true)] $servers = "" ) foreach($server in $servers) { if((Test-Connection -ComputerName $server -count 1 -ErrorAction 0)) { Write-Host "$server - Changing settings" sc.exe \\$server config "klnagent" start= auto ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Deploy-Service.ps1
Deploy-Service.ps1
<# .SYNOPSIS Deploy-Service.ps1 deploys IIS and Windows services to a list of servers which can be provided with a couple different methods. .DESCRIPTION Deploy-Service.ps1 deploys IIS services using appcmd.exe and Windows services using New-Service via Invoke-VMScript to allow execution on remote systems behind ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Check-KAgent.ps1
Check-KAgent.ps1
[cmdletbinding()] Param ( [alias("s")] #[Parameter(Mandatory=$true)] $server, $csv ) function GetCSV($csvfile) { if(!(Test-Path $csvfile)) { Write-Verbose "$($csvfile) does not exist. Try again." } elseif(!($csvfile.substring($csvfile.LastIndexOf(".")+1) -eq "csv")) { ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Stop-IIS.ps1
Stop-IIS.ps1
[cmdletbinding()] Param ( [alias("s")] [Parameter(Mandatory=$true)] $servers = "" ) if($servers.EndsWith(".txt")) { $servers = gc $servers } foreach($server in $servers) { if((Test-Connection -ComputerName $server -count 1 -ErrorAction 0)) { Write-Host "$server - Stopping W3SVC" ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Create-WeblogPurgeTaskXML.ps1
Create-WeblogPurgeTaskXML.ps1
$path = "c:\scripts\" #$servers = import-csv "$path\new_webservers.csv" $server = "server" foreach ($server in $servers) { $servername = $server.name.ToUpper() copy $path\WebLog_Purge_TEMPLATE.xml $path\WebLog_Purge_$servername.xml (Get-Content $path\WebLog_Purge_$servername.xml) | % {$_ -replace "S...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Fix-DriveMappings.ps1
Fix-DriveMappings.ps1
[cmdletbinding()] Param ( $servers ) if($servers.EndsWith(".txt")) { $servers = gc $servers } $script = @" diskpart.exe /s C:\Windows\system32\mylocaldrives.txt ping -n 11 127.0.0.1 >nul shutdown /r /t 0 "@ $cred = get-Credential foreach($server in $servers) { Write-Host "Working on $server"...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Remove-SCOMKey.ps1
Remove-SCOMKey.ps1
Import-Module PSRemoteRegistry $servers = @(import-csv("servers.csv")) foreach($server in $servers) { $isalive = Test-RegKey -CN $server.name -Hive LocalMachine -Key "Software" -Ping if($isalive) { $cstatus = "Connected" $exists = Test-RegKey -CN $server.name -Hive LocalMachine -Key "So...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-ServicesInfo.ps1
Get-ServicesInfo.ps1
[cmdletbinding()] Param ( [alias("s")] $server, $servers ) function CreateServicesObj($server,$status,$service="N/A",$startmode="N/A",$state="N/A",$user="N/A"){ $obj = New-Object PSObject -Property @{ Server = $server Status = $status Service = $service Start...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Check-ShavlikPatches.ps1
Check-ShavlikPatches.ps1
[cmdletbinding()] Param ( [alias("s")] [Parameter(Mandatory=$true)] $servers = "" ) function writeToObj($server,$status="N/A",$patches="N/A") { $obj= New-Object PSObject -Property @{ Server = $server Status = $status Patches = $patches } return $...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Import-IISConfig.ps1
Import-IISConfig.ps1
[cmdletbinding()] Param ( [Parameter(Mandatory=$true)]$servers, [Parameter(Mandatory=$true)][string]$site, [Parameter(Mandatory=$true)][string]$pool, [Parameter(ParameterSetName="Clean")][switch]$clean, [Parameter(ParameterSetName="Clean")][string]$service ) if($servers.EndsWith(".txt")) {...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Deploy-Files.ps1
Deploy-Files.ps1
[cmdletbinding()] Param ( [Parameter(ParameterSetName="Servers",Mandatory=$true)]$servers, [Parameter(ParameterSetName="Servers")]$path, [Parameter(ParameterSetName="TCS")]$datacenter, [Parameter(ParameterSetName="TCS")]$stack, [Parameter(ParameterSetName="TCS")]$role, [Parameter(Paramete...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Remove-ISAPIRewrite.ps1
Remove-ISAPIRewrite.ps1
[cmdletbinding()] Param ( $servers ) if($servers.EndsWith(".txt")) { $servers = gc $servers } $cred = get-Credential -Message "Local admin on the servers" foreach($server in $servers) { $i++ Write-Host "Working on $server" Write-Progress -Activity "Working on $server [$i/$($servers.count)...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Check-SCOMInstall.ps1
Check-SCOMInstall.ps1
$servers = @(import-csv("servers.csv")) foreach($server in $servers) { if((Test-Connection -ComputerName $server -count 1 -ErrorAction 0)) { $cstatus = "Connected" $exists = Test-RegKey -CN $server.name -Hive LocalMachine -Key "Software\Microsoft\Microsoft Operations Manager\3.0\Agent Managem...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Set-TimeZone.ps1
Set-TimeZone.ps1
[cmdletbinding()] Param ( $servers ) if($servers.EndsWith(".txt")) { $servers = gc $servers } $cred = get-Credential -Message "Local admin on the servers" foreach($server in $servers) { $script = 'C:\Windows\system32\tzutil.exe /s "Eastern Standard Time"' Invoke-VMScript -VM $server -ScriptText ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Create-VMCSV.ps1
Create-VMCSV.ps1
[cmdletbinding()] Param ( [parameter(Mandatory=$true)] $csv ) $connection = connect-viserver vcenter $report = @() $clusters = Get-Cluster foreach($cluster in $clusters) { Write-Host "Reading data from $($cluster.name)" $vms = Get-Cluster $cluster.Name | Get-VM if($vms) { for...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Find-TSSessions.ps1
Find-TSSessions.ps1
[cmdletbinding()] Param ( $domain, $server ) function WriteToObj($server,$state="N/A",$sessionid="N/A",$clientname="N/A",$useraccount="N/A",$connecttime="N/A",$idletime="N/A") { $obj = New-Object PSObject -Property @{ Server = $computer SessionID = $sessionid State = $stat...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-SNMPSettings.ps1
Get-SNMPSettings.ps1
[cmdletbinding()] Param ( $servers ) Import-Module psrr $datetime = Get-Date -format yyyy-MM-dd_HHmmss function GetDWord($server,$key,$value) { try { $key = Get-RegDWord -CN $server -Hive LocalMachine -Key $key -Value $value -ea "STOP" $dword = $key.Data } catch { $dword ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Set-RDP.ps1
Set-RDP.ps1
Import-Module PSRemoteRegistry $servers = gc pciservers.txt function GetDWord($server,$key,$value) { try { $exists = Get-RegDWord -CN $server -Hive LocalMachine -Key $key -Value $value -ea "STOP" -AsHex $dword = $exists.Data } catch { $dword = "Key does not exist" } retu...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-FolderInfo.ps1
Get-FolderInfo.ps1
[cmdletbinding()] param( $folder ) if($folder -eq $null) { $app = new-object -com Shell.Application; $browse = $app.BrowseForFolder(0, "Select Folder", 0, 0) if ($browse -eq $null) { Write-Host "You did not provide a valid path. Aborting"; Exit } $folder = $browse.self.path } if(!(Test-Pat...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Find-IPs.ps1
Find-IPs.ps1
[cmdletbinding()] Param ( $file ) $log = gc $file $ips = [regex]::matches($log,"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b") | sort value | select value -unique foreach($ip in $ips) { ([system.dns]::gethostbyaddress("$ip.value")).Hostname }
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Set-DNS.ps1
Set-DNS.ps1
None
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Set-NLA.ps1
Set-NLA.ps1
Import-Module PSRemoteRegistry $servers = gc stacks.txt function GetDWord($server,$key,$value) { try { $exists = Get-RegDWord -CN $server -Hive LocalMachine -Key $key -Value $value -ea "STOP" -AsHex $dword = $exists.Data } catch { $dword = "Key does not exist" } return $...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Uninstall-SCOM.ps1
Uninstall-SCOM.ps1
[cmdletbinding()] Param ( $servers ) if($servers.EndsWith(".txt")) { $servers = gc $servers } $cred = get-Credential -Message "Local admin on the servers" foreach($server in $servers) { $i++ Write-Host "Working on $server" Write-Progress -Activity "Working on $server [$i/$($servers.count)...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-DateTime.ps1
Get-DateTime.ps1
[cmdletbinding()] Param ( $servers ) if($servers.EndsWith(".txt")) { $servers = gc $servers } function writeToObj($server,$datetime="N/A") { $obj= New-Object PSObject -Property @{ Server = $server "Date/Time" = $datetime } return $obj } $allobj = @() foreach ($server i...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-TeaMemory.ps1
Get-TeaMemory.ps1
function GetProcessInfoByName($computername,$processName) { $obj = Get-WmiObject -computername $computername -class Win32_PerfFormattedData_PerfProc_Process | where{$_.name -like $processName+"*"} $privateworkingset = $obj.workingSetPrivate / 1MB $privateworkingset = "{0:N2}" -f $privateworkingset ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-ActiveNodes.ps1
Get-ActiveNodes.ps1
[cmdletbinding()] Param ( [alias("s")] [Parameter(Mandatory=$true)] $servers = "" ) if($servers.EndsWith(".txt")) { $servers = gc $servers } $allobj = @() foreach($server in $servers) { try { $name = gwmi win32_computersystem -computername $server | select -expand Name } catch { $name ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Install-SchTask.ps1
Install-SchTask.ps1
[cmdletbinding()] Param ( [parameter(Mandatory=$true)]$servers, [parameter(Mandatory=$true)]$xml, [parameter(Mandatory=$true)]$taskname = "Weblog_Purge", [parameter(Mandatory=$true)]$runas = "domain.local\svcTasks" ) if($servers.EndsWith(".txt")) { $servers = gc $servers } if(!(Test-Path $xml)...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-IEVersion.ps1
Get-IEVersion.ps1
[cmdletbinding()] Param ( $server ) function GetVersion($server) { if(!(Test-Connection -ComputerName $server -count 1 -ErrorAction 0)) { return "Failed to ping" } if(!(Test-Path "\\$server\c$\program files\internet explorer\iexplore.exe")) { return "iexplore.exe does not exist" } return (Get-I...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Set-LocalAdmins.ps1
Set-LocalAdmins.ps1
[cmdletbinding()] Param ( [alias("s")] [Parameter(ParameterSetName='server')] $server, [alias("c")] [Parameter(ParameterSetName='csv')] $csv, [alias("u")] $user, [switch]$add, [switch]$remove, [alias("g")] [switch]$group ) function Add-DomainGroupLocalAdm...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-PageFile.ps1
Get-PageFile.ps1
<# .SYNOPSIS Get-PageFile - Gathers pagefile settings from computers. .DESCRIPTION This script gathers pagefile settings from the specified computer(s) .NOTES File Name: Get-PageFile.ps1 Author: Al Iannacone Created: 2/8/2013 Modified: 1/8/2013 Version: 1.0 .EXAMPLE C:\PS>.\Ge...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Set-TakeNoAction.ps1
Set-TakeNoAction.ps1
[cmdletbinding()] Param ( [alias("s")] [Parameter(Mandatory=$true)] $server = "" ) if((Test-Connection -ComputerName $server -count 1 -ErrorAction 0)) { sc.exe \\$server failure "klnagent" reset= 0 actions= none/5000/none/5000/none/5000 } else { Write-Host "$server is offline" }
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Backup-Service.ps1
Backup-Service.ps1
[cmdletbinding()] Param ( [parameter(Mandatory=$true)] $service, [alias("cn")] $computername = $env:COMPUTERNAME, $backupdir = "C:\backups", [switch]$nohistory, [switch]$nooutboundbatfiles ) $date = Get-Date -format yyyy-MM-dd $servicepath = (Get-WmiObject -computername $compu...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Compare-Directories.ps1
Compare-Directories.ps1
[cmdletbinding()] param ( $source, $destinations, [switch]$showsuccess = $false, $logname = "compare.log", $rotation_threshold_mb = 10, [switch]$recursive = $false, [switch]$bysubfolder = $false, [switch]$excludeconfigs = $false ) if($destinations.EndsWith(".txt")) { $destin...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Fix-IIS.ps1
Fix-IIS.ps1
[cmdletbinding()] Param ( $servers ) if($servers.EndsWith(".txt")) { $servers = gc $servers } $cred = get-Credential -Message "Local admin on the servers" $times = @{"001" = "06:00:00";"002" = "06:00:00";"003" = "06:00:00";"004" = "06:00:00";"005" = "06:05:00";"006" = "06:05:00";"007" = "06:05:00";"008" =...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Check-LocalAdmin.ps1
Check-LocalAdmin.ps1
[cmdletbinding()] param () function CheckAccountOnComputers() { $Computers = Import-CSV -Path "c:\scripts\adminservers.csv" $cred = Get-Credential foreach ($Computer in $Computers) { $Computername = $Computer.Name.toupper() $Isonline = "OFFLINE" $PasswordValidationStatus = "FAILED"...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Reset-IIS.ps1
Reset-IIS.ps1
[cmdletbinding()] Param ( [Parameter(Position=0,Mandatory=$true)] $stack, $seconds = 120, $csv = "platform_servers.csv", $range ) $minutes = "{0:N2}" -f ($seconds/60) $config = Import-Csv $csv $servers = $config | ?{$_.role -eq "WEB" -and $_.stack -eq $stack} if($range) { $servers = $s...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Sync-Folder.ps1
Sync-Folder.ps1
[cmdletbinding()] Param( $Source, $Destination ) function Get-FileMD5 { Param([string]$file) $mode = [System.IO.FileMode]("open") $access = [System.IO.FileAccess]("Read") $md5 = New-Object System.Security.Cryptography.MD5CryptoServiceProvider $fs = New-Object System.IO.FileStream($fil...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Set-Service.ps1
Set-Service.ps1
[cmdletbinding()] Param ( [Parameter(ParameterSetName="Servers",Mandatory=$true)]$servers, [Parameter(ParameterSetName="MyPlatform")]$datacenter, [Parameter(ParameterSetName="MyPlatform")]$stack, [Parameter(ParameterSetName="MyPlatform")]$role, [Parameter(ParameterSetName="Servers",Mandatory=$...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-DNS.ps1
Get-DNS.ps1
[cmdletbinding()] param ( [parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [string[]] $servers = $env:computername, $scriptPath = (Get-Location).Path ) function AddtoObj($cn="N/A",$stat="N/A",$index="N/A",$ip="N/A",$pdns="N/A",$sdns="N/A",$tdns="N/A",$dhcp="N/A",$name="N/A") { ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Install-Certificate.ps1
Install-Certificate.ps1
function Add-Certificate { [CmdletBinding()] param ( [Parameter(Position=1, Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Path, [Parameter(Position=2, Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Password ) Write-Verbose...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-LocalAdmins.ps1
Get-LocalAdmins.ps1
# Get Local Administrators on dc01.domain.local # ./Get-LocalAdmins -server dc01.domain.local # Results will be output only the console # # Get Local Administrators for all servers in servers.txt # ./Get-LocalAdmins -servers listofservers.txt # Results will be output to the console and to localadminsreport.csv ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Search-EventLog.ps1
Search-EventLog.ps1
[cmdletbinding()] Param ( $ComputerName = "localhost", $Log = "security", $ProviderName, $Keywords, $ID, $Level, $StartTime = ((get-date).adddays(-1)), $EndTime, $UserID, $MaxEvents = 100, #[switch]$Oldest = $false, $Search, $Type, $creduser = "doma...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Export-IISService.ps1
Export-IISService.ps1
[cmdletbinding()] Param ( $servers, $service ) if($servers.EndsWith(".txt")) { $servers = gc $servers } $cred = get-Credential -Message "Local admin on the servers" foreach($server in $servers) { $i++ Write-Progress -Activity "Working on $server [$i/$($servers.count)]" -Status " " -Percen...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/RemoveFiles-RestartServices.ps1
RemoveFiles-RestartServices.ps1
$servers = @("SRV1","SRV2") $path = "g$\test" $service = "Windows Time" function GetNewestFile($server,$path) { try { $newest_file = (GCI \\$server\$path -ErrorAction "STOP" | sort LastWriteTime -Descending)[0] } catch { Write-Host "$($server): Failed to determine the newest file"; Write-Host ""; $newest...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Install-Software.ps1
Install-Software.ps1
[cmdletbinding()] Param ( $server, $stack, $file #$csv = "tcs_servers.csv", ) if($csv) { $config = Import-Csv $csv #$servers = $config | ?{$_.role -eq "WEB" -and $_.stack -eq $stack} if($range) { $servers = $servers | ?{$_.name -like "*-WEB$range" } } if($servers -eq $null) ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Set-PageFile.ps1
Set-PageFile.ps1
[cmdletbinding()] Param ( [Parameter(Position=1,ParameterSetName="SetPageFileSize")] [Alias('is')] [Int32]$InitialSize=4096, [Parameter(Position=2,ParameterSetName="SetPageFileSize")] [Alias('ms')] [Int32]$MaximumSize=4096, [Parameter(Position=3)] [Alias('dl')] [String]$DriveLetter="P", [Paramet...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Archive-CodeRepository.ps1
Archive-CodeRepository.ps1
[cmdletbinding()] Param ( $source, $destination, $zip ) $date = Get-Date -format yyyy-MM-dd if(Test-Path $source) { } else { Write-Host "$source does not exist" } #7zip the source to the destination #delete the original contents function Stolen { if(Test-Path \\fileserver\g$\path\$se...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Test-FileTransfer.ps1
Test-FileTransfer.ps1
[cmdletbinding()] param( $destination = "\\server.domain.local\c$", $text = "This is not a test`n", $folder = "." , $sizes = (500kb,5mb,10mb), $fileprefix = "TestFile", $testcount = 5 ) function convertSizeUnit($_size) { switch ($_size) { { $_ -ge 1TB } { $sizeText =...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-FirmwareWindows.ps1
Get-FirmwareWindows.ps1
[cmdletbinding()] Param ( $servers ) function writeToObj($server,$status="Offline",$firmware="N/A",$driver="N/A",$wwn="N/A") { $obj= New-Object PSObject -Property @{ Server = $server Status = $status Firmware = $firmware Driver = $driver WW...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Check-Time.ps1
Check-Time.ps1
[cmdletbinding()] Param ( $csv = "tcs_servers.csv", [Parameter(Mandatory=$true)] $stack, $range ) $config = Import-Csv $csv $servers = $config | ?{$_.stack -eq $stack} if($range) { $servers = $servers | ?{$_.name -like "*-$range" } } if($servers -eq $null) { Write-Host "Error in reading conf...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Get-Share.ps1
Get-Share.ps1
[CmdletBinding()] param( [Parameter(Position=0)] [System.String] $ComputerName = ‘.’, [Parameter(Position=1)] [System.String] $Share, [Parameter(Position=2)] [System.String] $OutputFile ) function Translate-AccessMask($val){ Switch ($val) { 2032127 {“FullControl”; break} 1179785 {“Read”; break} ...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Control-Service.ps1
Control-Service.ps1
[cmdletbinding()] Param ( [Parameter(ParameterSetName="Servers",Mandatory=$true)]$servers, [Parameter(ParameterSetName="TCS")]$datacenter, [Parameter(ParameterSetName="TCS")]$stack, [Parameter(ParameterSetName="TCS")]$role, [Parameter(ParameterSetName="Servers",Mandatory=$true)] [Paramete...
PowerShellCorpus/Github/abix-_powershell-practical/windows-server/Check-SCOM.ps1
Check-SCOM.ps1
[cmdletbinding()] Param ( $servers ) if($servers.EndsWith(".txt")) { $servers = gc $servers } $allobj = @() foreach($server in $servers) { $i++ [string]$folderexists = "Failed to query" Write-Progress -Activity "Working on $server [$i/$($servers.count)]" -Status " " -PercentComplete (($i/$s...
PowerShellCorpus/Github/abix-_powershell-practical/vcommander/vC-Install-MSMQ.ps1
vC-Install-MSMQ.ps1
Import-Module ServerManager Write-Host "Installing MSMQ-Server" Add-WindowsFeature MSMQ-Server | Out-Null
PowerShellCorpus/Github/abix-_powershell-practical/vcommander/vC-Install-NET351-Feature.ps1
vC-Install-NET351-Feature.ps1
Import-Module ServerManager Write-Host "Installing .NET 3.5.1 Feature" Add-WindowsFeature NET-Framework-Core | Out-Null
PowerShellCorpus/Github/abix-_powershell-practical/vcommander/vC-Install-WEB-Roles.ps1
vC-Install-WEB-Roles.ps1
Import-Module ServerManager Write-Host "Installing Application Server" Add-WindowsFeature Application-Server,AS-Web-Support,AS-WAS-Support,AS-HTTP-Activation,AS-TCP-Activation,AS-Named-Pipes | Out-Null Write-Host "Installing IIS Roles 1" Add-WindowsFeature File-Services,Web-Webserver,Web-Http-Redirect,Web-Asp-N...
PowerShellCorpus/Github/abix-_powershell-practical/vcommander/vC-Install-MSMQ-NET351-IIS.ps1
vC-Install-MSMQ-NET351-IIS.ps1
Import-Module ServerManager Write-Host "Installing MSMQ-Server" Add-WindowsFeature MSMQ-Server | Out-Null Write-Host "Installing .NET 3.5.1 Feature" Add-WindowsFeature NET-Framework-Core | Out-Null Write-Host "Installing IIS Role" Add-WindowsFeature Web-Server | Out-Null
PowerShellCorpus/Github/abix-_powershell-practical/vcommander/vC-Format-Drives.ps1
vC-Format-Drives.ps1
[cmdletbinding()] Param ( $temppath = "C:\Windows\Temp", $pg_disk = 0, $data_disk = 0 ) New-Item –path "$temppath\listdisk.txt" –itemtype file –force | OUT-NULL Add-Content –path "$temppath\listdisk.txt" “LIST DISK” $LISTDISK=(DISKPART.exe /S "$temppath\LISTDISK.TXT") $TOTALDISK=($LISTDISK.Count)...
PowerShellCorpus/Github/abix-_powershell-practical/vcommander/vC-Set-PageFile.ps1
vC-Set-PageFile.ps1
[cmdletbinding()] Param ( [Parameter(Position=1,ParameterSetName="SetPageFileSize")] [Alias('is')] [Int32]$InitialSize=4096, [Parameter(Position=2,ParameterSetName="SetPageFileSize")] [Alias('ms')] [Int32]$MaximumSize=4096, [Parameter(Position=3)] [Alias('dl')] [String]$DriveLetter="P", [Paramet...
PowerShellCorpus/Github/abix-_powershell-practical/vcommander/vC-Install-IIS.ps1
vC-Install-IIS.ps1
Import-Module ServerManager Write-Host "Installing IIS Role" Add-WindowsFeature Web-Server | Out-Null
PowerShellCorpus/Github/abix-_powershell-practical/misc/nspd.ps1
nspd.ps1
function SetGlobals() { $head = "<style>" $head = $head + "BODY{background-color:white;}" $head = $head + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}" $head = $head + "TH{border-width: 1px;padding: 3px;border-style: solid;border-color: black;backgroun...
PowerShellCorpus/Github/abix-_powershell-practical/misc/Create-SpamRule.ps1
Create-SpamRule.ps1
[cmdletbinding()] Param ( $type, $content, $score, $index, $seperator = "space", $indexFile = "Create-SpamRule-Index.txt", $scriptPath = (Get-Location).Path ) function drawMenu() { $index = getIndex Clear-Host Write-Host "Rule Index: $index" Write-Host "R...
PowerShellCorpus/Github/abix-_powershell-practical/misc/template.ps1
template.ps1
[cmdletbinding()] Param ( [alias("s")] $server, $csv ) function GetCSV($csvfile) { if(!(Test-Path $csvfile)) { Write-Verbose "$($csvfile) does not exist. Try again." } elseif(!($csvfile.substring($csvfile.LastIndexOf(".")+1) -eq "csv")) { Write-Verbose "$($csvfile) is not a CSV. Try again." ...
PowerShellCorpus/Github/abix-_powershell-practical/sharepoint/Get-SharepointGroupMembers.ps1
Get-SharepointGroupMembers.ps1
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $site = New-Object Microsoft.SharePoint.SPSite("http://yourservername/sites/yoursitecollection ") $groups = $site.RootWeb.sitegroups foreach ($grp in $groups) {"Group: " + $grp.name; foreach ($user in $grp.users) {" User: " + $user.name} } $...
PowerShellCorpus/Github/abix-_powershell-practical/sharepoint/Create-SharepointGroups.ps1
Create-SharepointGroups.ps1
[cmdletbinding()] Param ( [parameter(Mandatory=$true)] $name, [parameter(Mandatory=$true)] $url ) function EnableGroupSettings($groups,$groupname) { $groups = $site.RootWeb.sitegroups $group = $groups | where{$_.Name -eq $groupname} if($group) { Write-Host "Changing gro...
PowerShellCorpus/Github/abix-_powershell-practical/sharepoint/Find-UniqueLists.ps1
Find-UniqueLists.ps1
$status = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $site = New-Object Microsoft.SharePoint.SPSite("http://intranet") $webs = $site.AllWebs foreach($web in $webs) { $lists = $web.Lists foreach($list in $lists) { if($list.HasUniqueRoleAssignments) { Wr...
PowerShellCorpus/Github/abix-_powershell-practical/sharepoint/Migrate-SharepointGroup.ps1
Migrate-SharepointGroup.ps1
None
PowerShellCorpus/Github/abix-_powershell-practical/dell/Get-EQLUptime.ps1
Get-EQLUptime.ps1
#Requires -Version 3.0 function Get-MrEqlSANUptime { <# .SYNOPSIS Gets the uptime for one or more EqualLogic storage area network members. .DESCRIPTION Get-MrEqlSANUptime is a PowerShell function that retrieves the firmware version, last boot time, and number of days of uptime from one or more ...
PowerShellCorpus/Github/abix-_powershell-practical/dell/Update-CompellentServerAgent.ps1
Update-CompellentServerAgent.ps1
[cmdletbinding()] Param ( $servers, $site ) if(!$servers) { $servers = Import-Csv $csv if($stack) { $servers = $servers | ?{$_.stack -eq "$stack"} } if($role) { $servers = $servers | ?{$_.role -eq "$role"} } if($regex) { $servers = $servers | ?{$_.name -like "$regex"} } if($serve...