Could not flush the DNS Resolver cache: Function Failed During Execution. When flushing DNS cache


 This one is an easy one but it pops up every now and then when you try and flush the DNS cache on a machine.

To resolve this you need to restart the DNS Client service. You can do this by opening the Services management console by selecting windows button+r and typing services.msc, and then within the console restarting the DNS Client Service or starting it if it's turned off. Ensure the service is running and the startup type is set to automatic after you do so.





You can also achieve the same task through the command prompt by typing:
net stop "dns client" and then
net start "dns client"



Then you are done and will be able to successfully flush the dns cache on the machine.


Compare Active Directory Group Membership with Powershell

Here is a nice little Powershell script I wrote to compare group membership of two active directory users. You can use this script for many different purposes just edit the reference command and property to whatever object you wish to compare.

$UserReference = Get-ADPrincipalGroupmembership (Read-Host "Reference User")
$UserDifference = Get-ADPrincipalGroupmembership (Read-Host "Difference User")

Compare-object $UserReference $UserDifference -property SamAccountName


=> Means the Difference User is a member of  a group and the Reference User is not a member.
<= Means the Reference User is a member of the group and the Difference User is not a member.

You can also use the -IncludeEqual parameter to include groups both users are a member of that will be represented by the SideIndicator value of:  ==

RE Create Profile in Windows 7


To re create a user profile in windows 7 you must remove the profile from the registry otherwise the user will get a temp profile when they log in next.

To re create the profile you first have to re name the user folder in c:\users so you can retrieve the user data when they login to the new profile

Then you have to delete the profile in Advanced system properties by going to:
control panel>system and security>system
or
Right click computer and select properties

Select the "Advanced system settings" option
In the "User Profiles" field select "Settings"
Then select the profile you would like to remove and select "Delete"  



Then open the registry editor by selecting windows button + R and typing regedit and browse toHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
Select the profile you want to remove right click it and select "delete"

Restart the computer and get the user to log in to create their new profile and copy the users files over form the renamed folder.

Disable Server Manager on logon with Group Policiy

1. Select "Start," "Administrative Tools" and "Group Policy Management."

2.  Navigate to the "Local Computer Policy/Computer Configuration/Administrative Templates/System/Server Manager/" sub-folder in the left pane of the Group Policy Management window.

3.Double-click the "Do Not Display Server Manager Automatically at Logon" setting in the right pane.


4. Select "Enabled" and then Select "OK."

5. Link the GPO to the appropriate OU that contains your servers and you are done.

Log off user session on remote machine using Powershell

This is a handy little tool you can use with Powershell or in command prompt to see who is logged onto a remote machine and to end there session. Great for servers when you get the "too many users already logged in" message when trying to access a server.

1. You need to get the session ID of a user to log off by running the following command:
 qwinsta /server:servername









2. Enter the following command with the session ID at the end to log the user of:
logoff /server:servername (session id)

I used these commands to put together the following script. It will prompt you for the server name and give you the output of current open sessions then prompt you for the session ID to log off. Enjoy:

$server = read-host "Hostname"

qwinsta /server:$server

$ID = read-host "Session ID to log off"

logoff /server:$server $ID

Group Policy: Create mapped drive that is synced locally to be available offline.

If you have users that go to client sites and will not always have access to a network connection, and need access to some non confidential documents on the network creating Administratively assigned cashed files can be the way to go.

1. Create a new group policy object.





2. In Group policy Management Editor expand:
     User configuration> Administrative Templates> Network>
     Offline Files> Select Specify Administratively assigned Offline Files




3. Select Enabled.
    Then Select "Show"
    In the show contents window enter the name of the UNC path of the network share in the "Value Name"             field. Leave the value field blank and select ok. Creating the offline share is done.



And in the same policy we will map the drive for the share that we just made available offline.

4. Again in Group Policy Management Editor Expand:
    Preferences> Windows Settings> Drive Maps


1. Set Action to "Update" (This will re-map the drive if the user removes it)
    Set Location: the location of the network share.
    Select the "Reconnect" radio button
    Label as: Gives the share a desired name
    Select a drive letter
    select apply
   


































Link the GPO to the desired organizational unit that contains the users you wish to provide the offline files to. When they log in next they will have a mapped drive that will sync locally and be available to use offline.


Powershell: Reset user password and set to change at next logon

This powershell script can be used to reset user passwords quickly and force them to change it on their next logon. Copy this script into powerhell ISE and save it as a .ps1 file. When you run the script it will prompt you for the username. You can change the password variable to be whatever you want.

$Identity = read-host "Enter User name"
$password = P455w0rd

Set-adaccountpassword -Identity $Identity -reset -newpassword (ConvertTo-SecureString -AsPlainText $password -Force)
Set-aduser $user -changepasswordatlogon $true

or to statically assign the password use the following script:

Set-adaccountpassword -Identity (read-host "Enter User name") -reset
-NewPassword (Read-Host -AsSecureString "New Password")