Tag: server

Report of DNS settings on all Windows Servers via powershell

$AllServers=Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*" -and Enabled -eq 'True'}
$Servers = ForEach ($Server in $AllServers){

$Result=Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 'True'" -Property DNSServerSearchOrder -ComputerName $Server.Name

New-Object -TypeName PSObject -Property @{
ComputerName = $Server.Name -join ','
DNSServerSearchOrder = $Result.DNSServerSearchOrder -join ','

} | Select-Object ComputerName,DNSServerSearchOrder | Export-Csv -Path C:\Temp\ServerDNSSettings.csv -NoTypeInformation -Append
}

Run this from a domain controller and it will report the DNS servers set on the NIC card.

Search group policies for specific setting

Sometimes you need to search in a domain environment for a specific setting in GPO’s. This script will search through all the GPO’s in the domain and list the results at the end!

# Get the string you want to search for
$string = Read-Host -Prompt "What string do you want to search for?"

# Set the domain to search for GPOs
$DomainName = $env:USERDNSDOMAIN

# Find all GPO's in the current domain of logged on user
write-host "Finding all the GPO's in $DomainName"
Import-Module grouppolicy
$allGposInDomain = Get-GPO -All -Domain $DomainName
[string[]] $MatchedGPOList = @()

# Look through each GPO's XML for the string
Write-Host "Starting search...."
foreach ($gpo in $allGposInDomain) {
    $report = Get-GPOReport -Guid $gpo.Id -ReportType Xml
    if ($report -match $string) {
        write-host "********** Match found in: $($gpo.DisplayName) **********" -foregroundcolor "Green"
        $MatchedGPOList += "$($gpo.DisplayName)";
    } # end if
    else {
        Write-Host "No match in: $($gpo.DisplayName)"
    } # end else
} # end foreach
write-host "`r`n"
write-host "Results: **************" -foregroundcolor "Yellow"
foreach ($match in $MatchedGPOList) {
    write-host "Match found in: $($match)" -foregroundcolor "Green"
}

SNMP V3 on Ubuntu

We will be installing 3 packages to get SNMP up and running on Linux.

apt install snmpd snmp libsnmp-dev

OR

yum -y install net-snmp net-snmp-utils (if you are running yum)

Copy the default snmpd config file for backup purposes ( if you want to )

cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak

Empty the file out by doing the below

cat /dev/null > /etc/snmp/snmpd.conf

Stop the running service of snmpd by issuing the command

systemctl stop snmpd

Create your read only user account for SNMP V3. Replace “SUPERPASSWORD” and “USERNAME” with your required information

net-snmp-create-v3-user -ro -A SUPERPASSWORD -a SHA -X SUPERPASSWORD -x AES USERNAME

Now make the service start on bootup

systemctl enable snmpd

Start the service!

systemctl start snmpd

Remove “Network” from Windows Server Explorer sidebar

This is a registry edit that will remove the “network” icon from the file explorer window on Server 2012 R2 and most likely even Windows 7/8/10.

This is done by creating a registry key via GPO under User Configuration.

User Configuration, Preferences, Registry

Right click and choose New, Registry Item


Hive: HKEY_LOCAL_MACHINE
Key Path: SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\NonEnum
Value name: {F02C1A0D-BE21-4350-88B0-7367FC96EF3C}
Value type: REG_DWORD
Value Data (hex): 00000001

Windows Server 2012 RDP Logon Timeout

When using the interactive logon via RDP, you will find that you will be disconnected  if you do not login after the initial 30 seconds of the connection being established. This will cause the RDP window to close.

In my case, since this was a kiosk image being deployed across offices with only RDP running, it would look un-pleasent with the RDP session constantly restarting every 30 seconds. The below registry addition fixes/extends the timeout period.


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp

Create a DWORD key “LogonTimeout” in the above location and input the amount of time you want the initial logon screen to be displayed in seconds. I used 1800 seconds which is 30 minutes. Make sure to use decimal when inputting this value.

Once this is applied, reboot your machine and test!