Thursday, October 17, 2013
Powershell: Restart a Remote Machine
CLS $cname = Read-Host "Enter Machine Name or IP Address" Restart-Computer -computerName $cname -Force
Option 2: Enter the name directly in the code. cls Restart-Computer -computerName "EnterMachineNameHere" -Force
Option 3: Reboot multiple Machines
cls $cname ="Server01, Server02, Server03" Restart-Computer -computer $cname -force
Joe Piggee
Powershell: List services on remote machine
#Joe Piggee
--- Begin Code----
cls
gwmi win32_service -comp (gc c:\servers.txt) | select __server,name,startmode,state,status | Out-Gridview
--- End Code ---
Disable IPv6
By Joseph Piggee Sr.
http://support.microsoft.com/kb/929852
IPv6 can be disabled either through the DisabledComponents registry value or through the check box for the Internet Protocol Version 6 (TCP/IPv6) component in the list of items on the Networking tab for the properties of connections in the Network Connections folder. The following figure shows an example.
The DisabledComponents registry key affects all interfaces on the host. However, the check box on the Networking tab affects only the specific interface. The DisabledComponents registry value does not affect the state of the check box. Therefore, even if the DisabledComponents registry key is set to disable IPv6, the check box in the Networking tab for each interface can still be checked. This is expected behavior.
Note Unchecking the checkbox on a network adapter will not disable IPv6 on the host. It will unbind IPv6 from this adapter. To disable IPv6 on the host, follow the steps below.
To use the DisabledComponents registry value to check whether IPv6 was disabled, run the following command at a Windows command prompt:
reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents
You may receive the following error message:
ERROR: The system was unable to find the specified registry key or value.
If you receive this error message, the DisabledComponents registry value is not set. If the DisabledComponents value is set, it overrides the settings in the connection properties.
To enable or to disable IPv6 or to selectively enable or disable components of IPv6 automatically, click the Fix this problem link. Then, click Runin the File Download dialog box, and follow the steps in this wizard.
Backup Active Directory
Joe Piggee
- Open NTBACKUP by either going to Run, then NTBACKUP and pressing Enter or by going to Start / Accessories / System Tools. Or my personal method, Click Start/ Run/ Type NTBACKUP.
- If you are prompted by the Backup or Restore Wizard, I suggest you un-check the "Always Start in Wizard Mode" checkbox, and click on the Advanced Mode link.
- Inside NTBACKUP's main window, click on the Backup tab.
- Click to select the System State checkbox. Note you cannot manually select components of the System State backup. It's all or nothing.
- Enter a backup path for the BKF file. If you're using a tape device, make sure NTBACKUP is aware and properly configured to use it.
Press Start Backup. - The Backup Job Information pops out, allowing you to configure a scheduled backup job and other settings. For the System State backup, do not change any of the other settings except the schedule, if so desired. When done, press Start Backup. After a few moments of configuration tasks, NTBACKUP will begin the backup job.
- When the backup is complete, review the output and close NTBACKUP.
Windows Activation Error - 0x80072EE2 & 0x8007EFE
Joe Piggee
Error x80072EE2 & 0x8007EFE
This error normally indicates a connection issue. Very vague, but true. To fix this try the following:
Turn off the firewall, and retry activation
Check Date & time settings. If you needed to change anything on the date or time, restart the server before retrying the activation
Finally, make sure you aren't using a KMS key without a KMS server.
And verify the key code is correct.
To View or Change the Tombstone LifeTime
*To perform the following steps you'll need to be a member of the Enterprise Admins group.
To view or change attribute values by using ADSIEdit:
- On the Start menu, point to Run and then type ADSIEdit.msc and press Enter.
- In the next window, click Action-> Connect to
- In the center, change the connection point to "Select a well known Naming Context"
- Click the drop down menu, and select Configuration, then click OK
- Navigate to Configuration->CN=Services->CN=Windows NT->CN=Directory Service, Right click, and select properties
- Scroll down to "tombstoneLifetime" and double click to edit. It will be displaying the current value, which will be in days.
- When done just click OK.
- Click OK and then close ADSIEdit.
Query Active Directory for a particular User
--- Begin code -----
cls
# sending LDAP query to Active Directory
#Change sAMAccountName for your query
$searcher = [ADSISearcher]'(&(objectClass=User)(objectCategory=person)(sAMAccountName=jpiggee*))'
# finding first match
$searcher.FindOne()
# finding ALL matches
$searcher.FindAll()
#This would find all user accounts with a SamAccountName that starts with "tobias". You can now use this approach to easily find out where an account is located:
# find account location
$searcher.FindAll() | Select-Object -ExpandProperty Path
---End Code ----
Joe Piggee
Get More Detailed Information Using GetDirectoryEntry()
Wednesday, October 16, 2013
List machines with thier FQDN
<#
Reference URL: http://blogs.technet.com/b/heyscriptingguy/archive/2010/03/11/hey-scripting-guy-march-11-2010.aspx
This file will read Machinelist from a file, try to get their DNS information,
and append that output to a txt file.
You can use the above mentioned URL for more information and exaples of the Try\Catch\Finally
#>
ForEach ($entry in (Get-Content c:\scripts\machinelist2.txt)) {
Try {
[net.dns]::GetHostEntry($entry).Hostname | Out-File -FilePath c:\systems.txt -Append
} Catch {
$entry | Out-File -FilePath c:\scripts\Machine_WithFQDN.txt -Append
}
}
Joe P.