REM List out KMS Servers
nslookup -type=all _vlmcs._tcp
REM Set workgroup to use a particular KMS Server
slmgr.vbs /skms <KMS server>:<port>
These are just random notes and programs that may have incomplete descriptions. Any scripts or programs use at your risk
Thursday, July 6, 2017
Tuesday, May 9, 2017
Powershell: Get LUN ID with Diskspace
get-wmiobject Win32_DiskDrive | select name,caption, scsibus, scsilogicalunit, @{Name="size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}} | sort-object name
Tuesday, October 18, 2016
Powershell: Change UPN on list of users
I needed a script to bulk change a list of users to a new UPN i came up with this.
# $Users = gc c:\temp\users.txt | get-ADUser foreach ($User in $Users) $UserUPN = $User.UserPrincipalname $UserUPNwithOutDomain = ([regex]::matches($UserUPN, "([^@]+)")).value[0] Set-ADUser $User -userprincipalname "$UserUPNwithOutDomain@microsoft.com" }
Monday, May 9, 2016
Vmware: Powershell List all Datastores and virtual machines within
Purpose: Need to know if i had any empty datastores attached to my ESXi hosts. Came up with this one liner which will list out all datastores and the vms that are within empty or not.
get-datastore | select name, @{name="VM";e={get-datastore $_.name | get-vm } } | fl
Thursday, May 5, 2016
VMware: Powershell Query each ESX Hosts Syslog
This query will report each host and its current Syslog
get-vmhost | select Name,@{Name="SysLog"; Expression={(get-vmhostsyslogserver $_.name)}} | FL
Monday, April 18, 2016
Powershell: Get services and accounts used to run them on all computers using Jobs
cls
####################
#By Tony Unger
#Purpose: inventory all services and user accounts running them with jobs
#
##
$myCol = @()
$i =0
$servers = get-adcomputer -filter * | select -expand name
$scriptblock = {
param([string]$server)
get-wmiobject win32_service -computername $Server | select *
}
$ServersCount = $Servers.count
foreach($server in $Servers){
$i++
$running = @(Get-Job | Where-Object { $_.State -eq 'Running' })
Write-Progress -Activity "Gathering computer info" -status "Currently on $server -- $i of $ServersCount" -percentComplete ($i / $ServersCount*100)
if ($running.Count -le 50) {
Start-Job -ScriptBlock $scriptblock -Name $server -ArgumentList $server, $creds
}
else {
$running | Wait-Job
}
}
while ($running.Count -ge 1) {
sleep 1
$running = @(Get-Job | Where-Object { $_.State -eq 'Running' })
}
foreach ($job in Get-Job ){
$recjobs = Receive-Job -Keep -Job $job
foreach ($recjob in $recjobs){
$Detail = New-Object PSObject
$Detail | Add-Member Noteproperty Caption $recjob.Caption
$Detail | Add-Member Noteproperty Name $recjob.name
$Detail | Add-Member Noteproperty Startname $recjob.startname
$Detail | Add-Member Noteproperty Server $recjob.__SERVER
$myCol += $Detail
}
}
Wednesday, February 3, 2016
Powershell: RDP log user account off of all servers using jobs.
#Log User account off all servers
# Tony Unger
#
$Domain = "Microsoft.com"
$Servers = Get-ADComputer -Filter {(OperatingSystem -Like "Windows Server*")-and (enabled -eq "true")} -Property SamAccountName -Server $Domain Select -expand Name
$username = read-host "Enter Users Name:"
$i = 0
$scriptblock = {
param(
[string]$server,
$Username
)
$queryResults = (qwinsta /server:$server $Username| foreach { (($_.trim() -replace "\s+",","))} | ConvertFrom-Csv)
foreach ($queryResult in $queryResults){
Logoff /server:$server $queryResult.id
}
}
$TotalServersCount = $Servers.count
foreach($server in $Servers){
$i++
$running = @(Get-Job | Where-Object { $_.State -eq 'Running' })
Write-Progress -Activity "logging off user" -status "Currently on $server -- $i of $TotalServersCount" -percentComplete ($i / $Servers.count*100)
if ($running.Count -le 50) {
Start-Job -ScriptBlock $scriptblock -Name $server -ArgumentList $server, $username
}
else {
$running | Wait-Job
}
}
while ($running.Count -ge 1) {
sleep 1
$running = @(Get-Job | Where-Object { $_.State -eq 'Running' })
Remove-Job -State Completed
}
Subscribe to:
Posts (Atom)
Powershell: Microsoft Graph to add new roles to application registration
PowerShell Script Bulk add new roles to application registration in azure. Update $roles with ,Us...
-
Here is an excel document I created that will ping a list of nodes in column A and give results in column B. There are much better tools th...
-
#reads event logs for filter and exports to $Date = ( Get-Date ).AddMinutes(-30) $LogName = 'Security' $ProviderName = ...
-
Running solidcore you may run into a problem where you have to disable it with out using epo or the local CLI Here are the steps. ...