appwiz.cpl - Add/Remove programs
ncpa.cpl - Network Cards
Control - Control Panel
Netplwiz - local user accounts
LUSRMGR.MSC - local user and group accounts (as in Compmgmt.msc)
appwiz.cpl - Add/Remove programs
ncpa.cpl - Network Cards
Control - Control Panel
Netplwiz - local user accounts
LUSRMGR.MSC - local user and group accounts (as in Compmgmt.msc)
cls
# SubInACL #
#==PARAMETERS==
$Tool1="subinacl"
$UpDirOwner="MyDomain\Domain Admins"
$SubDirOwner="MyDomain\Domain Admins"
$UpDirUser="MyDomain\User"
$SubDirUser="MyDomain\User"
$UpDir="\\X.X.X.X\PSTs\" # use with /file parameter
$SubDir=-join($UpDir+"\*") # use with /subdirectories parameter
$errorlog="C:\temp\errorlog.txt"
$outputlog="C:\temp\outputlog.txt"
# ==OPTIONAL PARAMETERS==
# MD $UpDir # If you want to create UpDir you need to remove # sign from the beginnig of this line...
# ==OWNERSHIP==
& $Tool1 /errorlog=$errorlog /outputlog=$outputlog /file $UpDir /setowner=$UpDirOwner
ii $errorlog
& $Tool1 /errorlog=$errorlog /outputlog=$outputlog /subdirectories $SubDir /setowner=$SubDirOwner
ii $errorlog
#==PERMISSIONS==#
$FullControl = "F"
$Change = "C"
$ReadeXecute = "E"
#============#============#
DO
{
$menu=@"
1. Full Control $FullControl;
2. Change/Modify $Change;
3. Read eXecute $ReadeXecute;
Select a Permission by its number
"@
#============#============#
#Clear-Host
Write-Host ""
Write-Host "=Permission Menu=" -ForegroundColor Green
Write-Host ""
$Selection = Read-Host $Menu
#============#============#
$a = "N"
Switch ($Selection) { #Begin Switch
"1"{
$FullControl
& $Tool1 /file $UpDir /grant=$UpDirUser=$FullControl
& $Tool1 /subdirectories $SubDir /grant=$SubDirUser=$FullControl
Write-Host User $UpDirUser granted FullControl permissions on $UpDir folder and its subfolders
$a = "Y"
}
"2" {
$Change
& $Tool1 /file $UpDir /revoke=$UpDirUser
& $Tool1 /file $UpDir /grant=$UpDirUser=$Change
& $Tool1 /subdirectories $SubDir /revoke=$SubDirUser
& $Tool1 /subdirectories $SubDir /grant=$SubDirUser=$Change
Write-Host User $UpDirUser granted Change/Modify permissions on $UpDir folder and its subfolders
$a = "Y"
}
"3" {
$ReadeXecute
& $Tool1 /file $UpDir /revoke=$UpDirUser
& $Tool1/file $UpDir /grant=$UpDirUser=$ReadeXecute
& $Tool1 /subdirectories $SubDir /revoke=$SubDirUser
& $Tool1 /subdirectories $SubDir /grant=$SubDirUser=$ReadeXecute
Write-Host User $UpDirUser granted ReadeXecute permissions on $UpDir folder and its subfolders
$a = "Y"
}
default {
Write-Host "I don't understand what do you want to do." -ForegroundColor Yellow
}
} #end switch
}
UNTIL ($a -eq "Y")
# CHECK PERMISSIONS
& $Tool1 /file $UpDir
& $Tool1 /subdirectories $SubDir
ii $UpDir
# subinacl #
$Tool1="subinacl"
$Permission=""
$UpDirOwner="Domain\Domain Admins"
$SubDirOwner="Domain\Domain Admins"
$UpDirUser="Domain\User"
$SubDirUser="Domain\User"
$UpDir="\\X.X.X.X\Folder" # use with /file parameter
$errorlog="C:\temp\errorlog.txt"
$outputlog="C:\temp\outputlog.txt"
# Optional parameters
# MD $UpDir # If you want to create UpDir you need to remove # sign from the beginnig of this line...
$SubDir=-join($UpDir+"\*") # use with /subdirectories parameter
& $Tool1 /errorlog=$errorlog /outputlog=$outputlog /file $UpDir /setowner=$UpDirOwner
ii $errorlog
ii $outputlog
& $Tool1 /errorlog=$errorlog /outputlog=$outputlog /subdirectories $SubDir /setowner=$SubDirOwner
ii $errorlog
ii $outputlog
& $Tool1 /errorlog=$errorlog /outputlog=$outputlog /file $UpDir /grant=$UpDirUser=C
ii $errorlog
ii $outputlog
& $Tool1 /errorlog=$errorlog /outputlog=$outputlog /subdirectories $SubDir /grant=$SubDirUser=C
ii $errorlog
ii $outputlog
ii $UpDir
cls
## This script is prepared by Dr.Vlad
# The script searches for VMs by 3 parameters: VM name, Hostname, IP address
# The script outputs the found data in CSV file format, it is usable by itself or as basis for another script which uses it for fast searchin and making actions on found VM
# The script makes use of saved credentials ##
$vCs = 'vcsa-65', 'vcenter-5-5','vcenter-6-014'
$FileName = "V:\SCRIPTS\Scheduled\VM_REPORT.csv"
$FileNameDate = "V:\SCRIPTS\Scheduled\OldDates\VM_REPORT_$(get-date -f yyyy-MM-dd).csv"
$Title = "VMs_REPORT"
Disconnect-VIServer * -Confirm:$false
$PATH = ""
$VC = ""
$VC1 = ""
$VC2 = ""
$VC3 = ""
$User = ""
$Pass = ""
$Report = ""
$VMachines = ""
$Excel_Array = ""
$VMachines = ""
$VMName = ""
$DNSHostname = ""
$OS = ""
$Nics = ""
$IPAddress = ""
$IP = ""
$VMHost = ""
$CPU = ""
$Memory = ""
$Count = ""
$VM = ""
$VMPowerstate = ""
$VC_IP = ""
$Credentials = Import-Clixml "C:\cred\Credentials_Metropolinet.xml"
$User = $Credentials.UserName
$Pass = $Credentials.GetNetworkCredential().Password
$Excel_Array = New-Object System.Collections.ArrayList
FOREACH ($vC IN $vCs)
{
Connect-VIServer -User $User -Password $Pass $VC
$Count = (GET-VM | measure).count
IF($vC -eq "vcsa-65"){$VC_IP = "172.30.1.1"}
IF($vC -eq "vcenter-5-5"){$VC_IP = "172.30.10.151"}
IF($vC -eq "vcenter-6-014"){$VC_IP = "172.30.100.146"}
Write-Host $vC $VC_IP contain $Count VMs! -ForegroundColor GREEN
$VMachines = Get-View -ViewType Virtualmachine
FOREACH ($VMs IN $VMachines)
{
$VMName = $VMs.Name
$DNSHostname = $VMs.guest.hostname
$OS = $VMs.Config.GuestFullName
#$vCenter = ([uri]$VMs.Client.ServiceUrl).Host
$VMPowerstate = $VMs.RunTime.PowerState
$Nics = $VMs.summary.config.numEthernetCards
$IP = $VMs.Guest.Net.ipconfig.ipaddress.ipaddress -join ' '
$VMHost = (Get-View -Id $VMs.Runtime.Host -Property Name).Name
$CPU = $VMs.Config.Hardware.numCPU
$Memory = $VMs.Config.Hardware.memoryMB
$VMInfo = New-Object -Type PSObject
$VMInfo | Add-Member -MemberType NoteProperty -Name "VMName" -Value "$VMName" -Force
$VMInfo | Add-Member -MemberType NoteProperty -Name "DNSHostName" -Value "$DNSHostName" -Force
$VMInfo | Add-Member -MemberType NoteProperty -Name "VM_State" -Value "$VMPowerstate" -Force
$VMInfo | Add-Member -MemberType NoteProperty -Name "VM_OS" -Value "$OS" -Force
$VMInfo | Add-Member -MemberType NoteProperty -Name "vC_NAME" -Value "$VC" -Force
$VMInfo | Add-Member -MemberType NoteProperty -Name "vC_IP" -Value "$VC_IP" -Force
$VMInfo | Add-Member -MemberType NoteProperty -Name "VM_IP" -Value "$IP" -Force
# $VMInfo | Add-Member -MemberType NoteProperty -Name "VMHost" -Value "$VMHost" -Force
# $VMinfo | Add-Member -MemberType NoteProperty -Name "Nics" -Value "$Nics" -Force
# $VMInfo | Add-Member -MemberType NoteProperty -Name "CPU" -Value "$CPU" -Force
# $VMInfo | Add-Member -MemberType NoteProperty -Name "Memory" -Value "$Memory" -Force
$Excel_Array.Add($VMinfo) | Out-Null
$VMName = ""
$DNSHostname = ""
$OS = ""
$Nics = ""
$IPAddress = ""
$IP = ""
$VMHost = ""
$CPU = ""
$Memory = ""
$VM = ""
$VMPowerstate = ""
}
Disconnect-VIServer * -Confirm:$false
$VC_IP = ""
$VMachines = ""
}
# CD "$CurrentDir"
# $Excel_Array | Out-GridView -Title $Title
$Excel_Array | Export-CSV -path $FileName -NoTypeInformation
$Excel_Array | Export-CSV -path $FileNameDate -NoTypeInformation
$FileNameDate
# ii $FileName
$psISE.Options.FontSize = 12
<# This script utilizes the "AnyBox" GUI menu and saved credentials to search for a VM/computer/IP by hostname, VM name, or IP. The script retrieves data from a pre-prepared CSV file (the script for CSV preparation is also available on this site). Some parameters in the script will need to be changed to match the environment being used. #>
Clear-Host
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
$ErrorActionPreference= 'SilentlyContinue'
Add-PsSnapin VMware.VimAutomation.Core
Disconnect-VIServer * -Confirm:$false
$CSVName = "V:\SCRIPTS\Scheduled\VM_REPORT.csv" # Change this parameter
#============ZEROING$PARAMETERS============#
$vC_NAME = ""
$DataObj = ""
$VMName = ""
$VMName1 = ""
$VMName2 = ""
$VMName3 = ""
$VMName4 = ""
$VMName5 = ""
$VMName6 = ""
$VM_IP = ""
$VM_IP1 = ""
$VM_IP2 = ""
$VM_IP3 = ""
$VM_IP4 = ""
$VM_IP5 = ""
$VM_IP6 = ""
$vC = ""
$vC_NAME = ""
$vC_NAME1 = ""
$vC_NAME2 = ""
$vC_NAME3 = ""
$vC_NAME4 = ""
$vC_NAME5 = ""
$vC_NAME6 = ""
$vC_IP1 = ""
$vC_IP2 = ""
$vC_IP3 = ""
$vC_IP4 = ""
$vC_IP5 = ""
$vC_IP6 = ""
$DNSHostName = ""
$DNSHostName1 = ""
$DNSHostName2 = ""
$DNSHostName3 = ""
$DNSHostName4 = ""
$DNSHostName5 = ""
$DNSHostName6 = ""
$VM_State1 = ""
$VM_State2 = ""
$VM_State3 = ""
$VM_State4 = ""
$VM_State5 = ""
$VM_State6 = ""
#============CREDENTIALS============#
$User = "User@MyDomain.local" # Change this parameter
$Credential = Import-Clixml "C:\cred\Credentials_MyDomain.xml" # Change this parameter
$User = $Credential.UserName
$Pass = $Credential.GetNetworkCredential().Password
# $Name = Read-Host "Put a Name" #
# Write-Host = Enter VM/Host/IP for searching =
# GUI input box
[Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') > $NULL
$Name = [Microsoft.VisualBasic.Interaction]::InputBox('Enter VM/Host/IP for searching', 'VM Search Box')
Write-Host The Name you entered is "'$Name'"
$VMName = -join ($Name,"*")
$DNSHostName = -join ($Name,"*")
$VM_IP = $Name
$DataObj = Import-Csv $CSVName | Where-Object {($_."VMName" -like $VMName) -or ($_."DNSHostName" -like $DNSHostName) -or ($_."VM_IP" -like $VM_IP)} | Select VMName, DNSHostName, VM_IP, VM_State, VC_NAME, VC_IP
$DataObj | FT
$NUM = $DataObj.Count
Write-Host Count = $NUM
# $DataObj | Out-GridView -Title $Name
#============PARAMETERS============#
$VMName1 = $DataObj[0].VMName
$VMName2 = $DataObj[1].VMName
$VMName3 = $DataObj[2].VMName
$VMName4 = $DataObj[3].VMName
$VMName5 = $DataObj[4].VMName
$VMName6 = $DataObj[5].VMName
$VM_IP1 = $DataObj[0].VM_IP
$VM_IP2 = $DataObj[1].VM_IP
$VM_IP3 = $DataObj[2].VM_IP
$VM_IP4 = $DataObj[3].VM_IP
$VM_IP5 = $DataObj[4].VM_IP
$VM_IP6 = $DataObj[5].VM_IP
$vC_NAME1 = $DataObj[0].vC_NAME
$vC_NAME2 = $DataObj[1].vC_NAME
$vC_NAME3 = $DataObj[2].vC_NAME
$vC_NAME4 = $DataObj[3].vC_NAME
$vC_NAME5 = $DataObj[4].vC_NAME
$vC_NAME6 = $DataObj[5].vC_NAME
$vC_IP1 = $DataObj[0].vC_IP
$vC_IP2 = $DataObj[1].vC_IP
$vC_IP3 = $DataObj[2].vC_IP
$vC_IP4 = $DataObj[3].vC_IP
$vC_IP5 = $DataObj[4].vC_IP
$vC_IP6 = $DataObj[5].vC_IP
$DNSHostName1 = $DataObj[0].DNSHostName
$DNSHostName2 = $DataObj[1].DNSHostName
$DNSHostName3 = $DataObj[2].DNSHostName
$DNSHostName4 = $DataObj[3].DNSHostName
$DNSHostName5 = $DataObj[4].DNSHostName
$DNSHostName6 = $DataObj[5].DNSHostName
$VM_State1 = $DataObj[0].VM_State
$VM_State2 = $DataObj[1].VM_State
$VM_State3 = $DataObj[2].VM_State
$VM_State4 = $DataObj[3].VM_State
$VM_State5 = $DataObj[4].VM_State
$VM_State6 = $DataObj[5].VM_State
$VMName_INFO = ""
$VM_IP_INFO = ""
$vC_NAME_INFO = ""
$vC_IP_INFO = ""
$DNSHostName_INFO = ""
$VM_State_Info = ""
#============MENU============#
DO
{
$menu=@"
1. $VMName1; $DNSHostName1; $VM_IP1; $VM_State1
2. $VMName2; $DNSHostName2; $VM_IP2; $VM_State2
3. $VMName3; $DNSHostName3; $VM_IP3; $VM_State3
4. $VMName4; $DNSHostName4; $VM_IP4; $VM_State4
5. $VMName5; $DNSHostName5; $VM_IP5; $VM_State5
6. $VMName6; $DNSHostName6; $VM_IP6; $VM_State6
Select a VM Name by it's number
"@
#============#============#
#Clear-Host
Write-Host ""
Write-Host "=VM Menu=" -ForegroundColor Cyan
Write-Host ""
$Selection = Read-Host $Menu
#============#============#
$a = "N"
Switch ($Selection) { #Begin Switch
"1"{
$VMName_INFO = $VMName1
$VM_IP_INFO = $VM_IP1
$vC_NAME_INFO = $vC_NAME1
$vC_IP_INFO = $vC_IP1
$DNSHostName_INFO = $DNSHostName1
$VM_State_Info = $VM_State1
Connect-VIServer -User $User -Password $Pass $VC_IP_INFO
Write-Host VM "'$VMName_INFO'" consists in vC "'$vC_NAME_INFO'" "'$VC_IP_INFO'"
Write-Host DNSHostName = "'$DNSHostName_INFO'" and IP = "'$VM_IP_INFO'" and Status = "'$VM_State_Info'"
$a = "Y"
}
"2" {
$VMName_INFO = $VMName2
$VM_IP_INFO = $VM_IP2
$vC_NAME_INFO = $vC_NAME2
$vC_IP_INFO = $vC_IP2
$DNSHostName_INFO = $DNSHostName2
$VM_State_Info = $VM_State2
Connect-VIServer -User $User -Password $Pass $VC_IP_INFO
Write-Host VM "'$VMName_INFO'" consists in vC "'$vC_NAME_INFO'" "'$VC_IP_INFO'"
Write-Host DNSHostName = "'$DNSHostName_INFO'" and IP = "'$VM_IP_INFO'" and Status = "'$VM_State_Info'"
$a = "Y"
}
"3" {
$VMName_INFO = $VMName3
$VM_IP_INFO = $VM_IP3
$vC_NAME_INFO = $vC_NAME3
$vC_IP_INFO = $vC_IP3
$DNSHostName_INFO = $DNSHostName3
$VM_State_Info = $VM_State3
Connect-VIServer -User $User -Password $Pass $VC_IP_INFO
Write-Host VM "'$VMName_INFO'" consists in vC "'$vC_NAME_INFO'" "'$VC_IP_INFO'"
Write-Host DNSHostName = "'$DNSHostName_INFO'" and IP = "'$VM_IP_INFO'" and Status = "'$VM_State_Info'"
$a = "Y"
}
"4" {
$VMName_INFO = $VMName4
$VM_IP_INFO = $VM_IP4
$vC_NAME_INFO = $vC_NAME4
$vC_IP_INFO = $vC_IP4
$DNSHostName_INFO = $DNSHostName4
$VM_State_Info = $VM_State4
Connect-VIServer -User $User -Password $Pass $VC_IP_INFO
Write-Host VM "'$VMName_INFO'" consists in vC "'$vC_NAME_INFO'" "'$VC_IP_INFO'"
Write-Host DNSHostName = "'$DNSHostName_INFO'" and IP = "'$VM_IP_INFO'" and Status = "'$VM_State_Info'"
$a = "Y"
}
"5" {
$VMName_INFO = $VMName5
$VM_IP_INFO = $VM_IP5
$vC_NAME_INFO = $vC_NAME5
$vC_IP_INFO = $vC_IP5
$DNSHostName_INFO = $DNSHostName5
$VM_State_Info = $VM_State5
Connect-VIServer -User $User -Password $Pass $VC_IP_INFO
Write-Host VM "'$VMName_INFO'" consists in vC "'$vC_NAME_INFO'" "'$VC_IP_INFO'"
Write-Host DNSHostName = "'$DNSHostName_INFO'" and IP = "'$VM_IP_INFO'" and Status = "'$VM_State_Info'"
$a = "Y"
}
"6" {
$VMName_INFO = $VMName6
$VM_IP_INFO = $VM_IP6
$vC_NAME_INFO = $vC_NAME6
$vC_IP_INFO = $vC_IP6
$DNSHostName_INFO = $DNSHostName6
$VM_State_Info = $VM_State6
Connect-VIServer -User $User -Password $Pass $VC_IP_INFO
Write-Host VM "'$VMName_INFO'" consists in vC "'$vC_NAME_INFO'" "'$VC_IP_INFO'"
Write-Host DNSHostName = "'$DNSHostName_INFO'" and IP = "'$VM_IP_INFO'" and Status = "'$VM_State_Info'"
$a = "Y"
}
default {
Write-Host "I don't understand what do you want to do." -ForegroundColor Yellow
}
} #End of switch
}
UNTIL ($a -eq "Y")
#============#============#
# This part of code is using "AnyBox" feature
# $Open_Console = Get-VM $VMNAME | Open-VMConsoleWindow
$Prompt = New-AnyBoxPrompt `
-Name 'Action' -InputType Text `
-Message ''$VMNAME_INFO' ; Choose an action' `
-DefaultValue 'Open-Console' `
-ValidateSet @('Open-Console', 'Open-RDP', 'Restart_Promptly', 'Hard_Reset', 'Shutdown_Promptly', 'Start-VM', 'Extend_C:', 'Other') `
$q = Show-AnyBox -Icon 'Question' -Prompt $prompt -Buttons 'OK'
$OK = $q.OK
$Action = $q.Action
If(($OK -eq $True) -and ($Action -eq "Open-Console")){ Get-VM $VMNAME_INFO | Open-VMConsoleWindow }
If(($OK -eq $True) -and ($Action -eq "Open-RDP")){ mstsc /v:"$DNSHostName_INFO":3389 }
If(($OK -eq $True) -and ($Action -eq "Restart_Promptly")){ Get-VM $VMNAME_INFO | Open-VMConsoleWindow ; Get-VM $VMNAME_INFO | Restart-VMGuest }
If(($OK -eq $True) -and ($Action -eq "Hard_Reset")){ Get-VM $VMNAME_INFO | Open-VMConsoleWindow ; Get-VM $VMNAME_INFO | Restart-VM }
If(($OK -eq $True) -and ($Action -eq "Shutdown_Promptly")){ Get-VM $VMNAME_INFO | Open-VMConsoleWindow ; Get-VM $VMNAME_INFO | Shutdown-VMGuest}
If(($OK -eq $True) -and ($Action -eq "Start-VM")){ Get-VM $VMNAME_INFO | Open-VMConsoleWindow ; Get-VM $VMNAME_INFO | Start-VM }
Write-Host ""
Disconnect-VIServer * -Confirm:$false
<#
Additional tasks to do:
Add opening Excel-CSV;
Rename VM;
Create snapshots: Get-VM | Get-Snapshot
Delete snapshot: Get-VM | Get-Snapshot | Remove Snapshot
Move-VM to another Datastore;
Move Disk to another VM;
Extend disks space (the most difficult is to identify match between VMDK number and Windows guest disk letter because there is no full proof solution).
#>
File:
F : Full Control
C : Change
R : Read
P : Change Permissions
O : Take Ownership
X : eXecute
E : Read eXecute
W : Write
D : Delete
CD C:\Program Files (x86)\Windows Resource Kits\Tools\
subinacl /errorlog="c:\temp\errorlog.txt" /outputlog="c:\temp\outputlog.txt" /file "\\Server\Share" /setowner=Domain\User
subinacl /errorlog="c:\temp\errorlog.txt" /outputlog="c:\temp\outputlog.txt" /file "\\Server\Share" /grant=Domain\User=C
subinacl /errorlog="c:\temp\errorlog.txt" /outputlog="c:\temp\outputlog.txt" /subdirectories \\Server\Share\* /grant=Domain\User=C
subinacl /help /grant
subinacl /verbose=1 /file c:\temp /display
subinacl /file c:\temp /grant==Domain\User=C
subinacl /file c:\temp /deny==Domain\User=W
subinacl /subdirectories c:\temp\* /grant=Domain\User=C
subinacl /file * /replace=Domain\User1=Domain\User2
subinacl /subdirectories c:\temp\* /revoke=Domain\User
subinacl /subdirectories c:\temp\* /cleandeletedsidsfrom=Domain
subinacl /testmode /subdirectories c:\temp\* /grant=Domain\User=F
subinacl /errorlog="c:\temp\errorlog.txt" /outputlog="c:\temp\outputlog.txt" /subdirectories c:\temp\* /grant=Domain\User=C
WSUS GUI console could give sometimes connection error.
You may change the batch in accordance to your environment.
With this line you can check where the MMC folder is resides.
%AppData%\Microsot\MMC
==Start of Batch==
IISRESET
Timeout /T 5
C:
::
CD C:\Users\vlad\AppData\Roaming\Microsoft\MMC
del wsus
CD C:\Windows\System32\inetsrv
appcmd start apppool wsuspool
CD C:\Program Files\Update Services\AdministrationSnapin\
start /B wsus.msc
==End of Batch==
Run the batch as a administrator.
But it is better to solve the problem for ever then temporarily remediate it.
Change the IIS Application Pool definitions in accordance with the next pictures.