Tuesday, 1 December 2015
Quickly move all the FSMO roles to a new DC with PowerShell
Move-ADDirectoryServerOperationMasterRole -Identity dC0 –OperationMasterRole 0,1,2,3,4
Tuesday, 24 November 2015
Moving SUSDB.MDF to another drive
Stop the services locking the SUSDB open
net stop "update services"
net stop "w3svc"
Use SQLCMD to drop the database.
sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q "sp_detach_db 'SUSDB'"
Use xcopy to move the SUSDB.mdf and SUSDB_LOG.ldf to the D:\
Reattach the database
sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q "sp_attach_db @dbname=N'SUSDB',\
@filename1=N'D:\WSUS\SUSDB\SUSDB.mdf',\
@filename2=D'D:\WSUS\SUSDB\SUSDB_log.ldf'"
Start the services
net start "update services"
net start "w3svc"
Wednesday, 18 November 2015
Protecting AD OUs from accidental deletion
Before carrying out an AD migration I always like to the the best practice analysers. 9 times out of ten these days we see that the BPA warns that all OUs should be protected against accidental deletion.
You can use the simple line of PoSh to protect all OUs and eradicate the BPA warning.
Get-ADOrganizationalUnit -filter * -Properties ProtectedFromAccidentalDeletion | where {$_.ProtectedFromAccidentalDeletion -eq $false} | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true
You can use the simple line of PoSh to protect all OUs and eradicate the BPA warning.
Get-ADOrganizationalUnit -filter * -Properties ProtectedFromAccidentalDeletion | where {$_.ProtectedFromAccidentalDeletion -eq $false} | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true
Thursday, 29 October 2015
Installing .NET 3.5 on Windows 2012
There are two ways to install .NET 3.5 onto Windows 2012, this is also required if you want to install SQL Studio Manager.
1. Powershell (As Admin)
Install-WindowsFeature Net-Framework-Core -source \\network\share\sxs
2. Old Fashion Command Line (As Admin)
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:d:\sources\sxs
Protecting All OUs in the Domain from Accidental Deletion
You can issue this line of PoSh at a domain controller to prevent any accidental deletion of AD OUs
Get-ADOrganizationalUnit -Filter 'Name -like "*"' | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true
Get-ADOrganizationalUnit -Filter 'Name -like "*"' | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true
Wednesday, 21 October 2015
Wednesday, 17 June 2015
Disable Windows firewall from PowerShell
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
Thursday, 11 June 2015
Fixing "Not Present" Network Adapters in Windows 2012 core mode
I had a situation with a customer who had 2x 10GbE NICs in a Dell PowerEdge R720 server. The Network Adapters as seen below show "Not Present" It didn't seem to matter if there was a cable present or not.
We even tried disabling and re-enabling the adapter but this didn't help. A case was raised with Dell SST, first the NIC and the raiser was replaced. This did not fix it. We tried moving the Adpater to another slot and it worked, but to keep symmetry the customer wanted the adapter in this specific slot. Next Dell replaced the mainboard and CPU, this also did not fix the problem. We booted into a Linux liveCD and we could see that the NIC was functioning so this pointed to Windows.
The Deployment was using Windows 2012 R2 core mode so we could not use Windows Device Manager to see what was happening. I never seem to be able to get Device Manager working remotely. So I turned to DevManView which if free from NirSoft. What we noticed was that the card was listed twice. we tried disabling re-enabling the card but this didn't help. Fortunatly we can use DevManView to open the related Registry key. Because the nornal Administrator account doesn't have permission to remove device based reg keys, you can run RegEdit as the system account but using PsExec from Microsoft. We used DevManView to open the keys and delete them! Excercise caution here, know what you are doing with the registry and have backups, you have been warned!
The server was rebooted and the devices were re-detected and this corrected the problem!
www.nirsoft.net/utils/device_manager_view.html
psexec -i -d -s c:\windows\regedit.exe
We even tried disabling and re-enabling the adapter but this didn't help. A case was raised with Dell SST, first the NIC and the raiser was replaced. This did not fix it. We tried moving the Adpater to another slot and it worked, but to keep symmetry the customer wanted the adapter in this specific slot. Next Dell replaced the mainboard and CPU, this also did not fix the problem. We booted into a Linux liveCD and we could see that the NIC was functioning so this pointed to Windows.
The Deployment was using Windows 2012 R2 core mode so we could not use Windows Device Manager to see what was happening. I never seem to be able to get Device Manager working remotely. So I turned to DevManView which if free from NirSoft. What we noticed was that the card was listed twice. we tried disabling re-enabling the card but this didn't help. Fortunatly we can use DevManView to open the related Registry key. Because the nornal Administrator account doesn't have permission to remove device based reg keys, you can run RegEdit as the system account but using PsExec from Microsoft. We used DevManView to open the keys and delete them! Excercise caution here, know what you are doing with the registry and have backups, you have been warned!
The server was rebooted and the devices were re-detected and this corrected the problem!
www.nirsoft.net/utils/device_manager_view.html
psexec -i -d -s c:\windows\regedit.exe
Tuesday, 28 April 2015
How to list installed application in Windows 2012 core mode
You can use PowerShell to list all the installed applications on Windows 2012 core mode.
Get-WmiObject Win32_Product | ft -Auto
Monday, 27 April 2015
VSS fixup script
If Windows backup is failing due to VSS issues, you can try this script to re-register all the VSS DLLs. This should be a last resort after all other avenues have been investigated.
net stop "File Replication Service"
net stop "DHCP Server"
net stop "DFS Replication"
net stop "Background Intelligent Transfer Service"
net stop "System Event Notification Service"
net stop "Background Intelligent Transfer Service"
net stop "COM+ Event System"
net stop "Microsoft Software Shadow Copy Provider"
net stop "Volume Shadow Copy"
cd /d %windir%\system32
net stop vss
net stop swprv
regsvr32 /s ole32.dll
regsvr32 /s oleaut32.dll
regsvr32 /s vss_ps.dll
vssvc /register
regsvr32 /s /i swprv.dll
regsvr32 /s /i eventcls.dll
regsvr32 /s es.dll
regsvr32 /s stdprov.dll
regsvr32 /s vssui.dll
regsvr32 /s msxml.dll
regsvr32 /s msxml4.dll
regsvr32 /s msxml3.dll
net start "COM+ Event System"
net start "System Event Notification Service"
net start "Microsoft Software Shadow Copy Provider"
net start "Volume Shadow Copy"
net start "File Replication Service"
net start "DHCP Server"
net start "DFS Replication"
net start "Background Intelligent Transfer Service"
net stop "File Replication Service"
net stop "DHCP Server"
net stop "DFS Replication"
net stop "Background Intelligent Transfer Service"
net stop "System Event Notification Service"
net stop "Background Intelligent Transfer Service"
net stop "COM+ Event System"
net stop "Microsoft Software Shadow Copy Provider"
net stop "Volume Shadow Copy"
cd /d %windir%\system32
net stop vss
net stop swprv
regsvr32 /s ole32.dll
regsvr32 /s oleaut32.dll
regsvr32 /s vss_ps.dll
vssvc /register
regsvr32 /s /i swprv.dll
regsvr32 /s /i eventcls.dll
regsvr32 /s es.dll
regsvr32 /s stdprov.dll
regsvr32 /s vssui.dll
regsvr32 /s msxml.dll
regsvr32 /s msxml4.dll
regsvr32 /s msxml3.dll
net start "COM+ Event System"
net start "System Event Notification Service"
net start "Microsoft Software Shadow Copy Provider"
net start "Volume Shadow Copy"
net start "File Replication Service"
net start "DHCP Server"
net start "DFS Replication"
net start "Background Intelligent Transfer Service"
Friday, 24 April 2015
Finding volume GUIDs from powershell
This peice of PowerShell will find all the volume GUIDs, their name and free space.
Get-WmiObject -class Win32_Volume -computername localhost | where-object {$_.name -like "\\?\*"} | select-object label, name, @{ Label = "Capacity(GB)" ; Expression = { "{0:N2}" -f ($_.capacity/1024/1024/1024) } },@{ Label = "Freespace(GB)" ; Expression = { "{0:N2}" -f ($_.freespace/1024/1024/1024) } } | ft -auto
Get-WmiObject -class Win32_Volume -computername localhost | where-object {$_.name -like "\\?\*"} | select-object label, name, @{ Label = "Capacity(GB)" ; Expression = { "{0:N2}" -f ($_.capacity/1024/1024/1024) } },@{ Label = "Freespace(GB)" ; Expression = { "{0:N2}" -f ($_.freespace/1024/1024/1024) } } | ft -auto
Tuesday, 17 March 2015
Changing a hosts display name case in SCVMM
If you want to change the displayed case of hosts in SCVMM to upper case below this the SQL query you need to execute on the SCVMM SQL database.
Stop the System Center Virtual Machine Manager and System Center Virtual Machine Manager Agent service on the SCVMM server.
Open SQL Studio manager, select the VirtualManagerDB and take a backup first! Then paste this code into a new query window and select execute.
UPDATE [VirtualManagerDB].[dbo].[tbl_ADHC_Host]
SET [ComputerName] = UPPER(LEFT([ComputerName], CHARINDEX('.', [ComputerName], 1) -1)) +
RIGHT([ComputerName], LEN([ComputerName]) - CHARINDEX('.', [ComputerName], 1) + 1)
Start the System Center Virtual Machine Manager and System Center Virtual Machine Manager Agent service on the SCVMM server.
Job done!
Stop the System Center Virtual Machine Manager and System Center Virtual Machine Manager Agent service on the SCVMM server.
Open SQL Studio manager, select the VirtualManagerDB and take a backup first! Then paste this code into a new query window and select execute.
SELECT [ComputerName], UPPER(LEFT([ComputerName], CHARINDEX('.', [ComputerName], 1) -1)) +
RIGHT([ComputerName], LEN([ComputerName]) - CHARINDEX('.', [ComputerName], 1) + 1)
FROM [VirtualManagerDB].[dbo].[tbl_ADHC_Host]
RIGHT([ComputerName], LEN([ComputerName]) - CHARINDEX('.', [ComputerName], 1) + 1)
FROM [VirtualManagerDB].[dbo].[tbl_ADHC_Host]
UPDATE [VirtualManagerDB].[dbo].[tbl_ADHC_Host]
SET [ComputerName] = UPPER(LEFT([ComputerName], CHARINDEX('.', [ComputerName], 1) -1)) +
RIGHT([ComputerName], LEN([ComputerName]) - CHARINDEX('.', [ComputerName], 1) + 1)
Job done!
Using PowerShell Enter-PSSession when your computer isn't on the domain.
Quite often when i'm at a customers site I need to work on their servers. Each time I go to site I don't join my laptop to the customers domain. The problem with this is that when you use the Enter-PSSession command you get an error message about the fact that your computer is not joined to the domain that the server is.
This also presumes you have enabled PSRemoing on the destination host with this command:
Enable-PSRemoting -Force
Here is the work around; Enter the first command on you computer once only. This tells your computer to trust the identify of any remote computers. This should not be done on non technical users computers as the security implications are obvious.
Set-Item WSMAN:\Localhost\Client\TrustedHosts -Value * -Force
The command below will connect you to the computer of your choice, you will need change the IP address or substitute a computer name, you will also need to change the domain and username to an account that is active on the server.
Enter-PSSession -ComputerName 0.0.0.0 -Credential domain\username -Authentication negotiate
This also presumes you have enabled PSRemoing on the destination host with this command:
Enable-PSRemoting -Force
Here is the work around; Enter the first command on you computer once only. This tells your computer to trust the identify of any remote computers. This should not be done on non technical users computers as the security implications are obvious.
Set-Item WSMAN:\Localhost\Client\TrustedHosts -Value * -Force
The command below will connect you to the computer of your choice, you will need change the IP address or substitute a computer name, you will also need to change the domain and username to an account that is active on the server.
Enter-PSSession -ComputerName 0.0.0.0 -Credential domain\username -Authentication negotiate
Labels:
domain,
Enable-PSRemoting,
Enter-PSSession,
not on the domain
Wednesday, 11 March 2015
DHCP scope exhausted with BAD_ADDRESS enteries
I noticed a new VM would not get a DHCP address from one of the customers DC's, after remoting into the DC we could see that the scope was full. Upon further inspection the scope had been filled with BAD_ADDRESS entries. We selected all the BAD_ADDRESSES and deleted them, but within minutes it was full again. I knew it had to be some of the new equipment we had plugged in, this was disconnected and I used the PoSh below to see if any new BAD_ADDRESS entries emerged.
Get-DhcpServerv4Lease -ScopeId "192.168.221.0" | Where {$_.HostName -eq "BAD_ADDRESS"}
Isolated the problem to two new downstream Force 10 MXL switches that have DHCP enabled in the default VLAN. The commands below were issued on the switch to resolve the problem with the scope filling.
>interface VLAN 1
>no IP address DHCP
>do wr
The PoSh command above was used to make sure that no new BAD_ADDRESS entries existed.
Thursday, 12 February 2015
Troubleshooting intermittent pings
Troubleshooting intermittent pings can be a pain in the rear. Here are some steps I have used to isolate the issue.
I am working with a customer who is having a Hyper-V cluster, after getting the Network Adapters sorted out I noticed the RDP connectivity to the server was poor. A ping to the default gateway revealed high ping latency and a good handful of request time-outs.
I am working with a customer who is having a Hyper-V cluster, after getting the Network Adapters sorted out I noticed the RDP connectivity to the server was poor. A ping to the default gateway revealed high ping latency and a good handful of request time-outs.
- Updated the drivers - No change.
- Changed the CAT6 cable - No change.
- Disabled VMQ - No change.
- Plugged my laptop in to the same cable - Same issue, Bingo! This turned out to be a red herring. I updated my drivers and plugged the power in and that resolved the laptop ping issue.
- Tried another laptop on the same cable - It was fine, 1ms.
- Tried another 1GbE NIC to eliminate the LBFO driver - still the same.
- Tried a 10GbE - Seems to be stable, odd.
- Tried another switch - Seems to be stable, odd.
- Flatted the server, installed Windows 2012 R2 again and test the ping, it was fine, odd!
- Repeated all the configuration steps one at a time each time testing the ping, still OK.
- Joined the domain, BAM! Pings all over the shop.
- Tried safe mode, Seems to be stable 1ms!
- Removed the server from the domain, seems to be stable 1ms.
- Added the server back to the domain, pings latent and intermittent again.
- Stop the Base Filter Engine (stop-service BFE - force), seems to be stable 1ms.
- Uninstall the Broadcom driver and use the OOB driver from Microsoft, seems to be stable 1ms.
Update: After creating some VMs the problem moved inside some VMs. The solution was to change the Broadcom 1GbE NICs for Intel x350-t NICs.
Hardware, Dell PowerEdge R720, 1GbE & 10GbE Broadcom NICs. Switch HP 5400
Subscribe to:
Posts (Atom)