Archive for the ‘Uncategorized’ Category

How to delete a host that is in (pending) state in SCVMM

Monday, July 24th, 2017

When deleting a Hyper-V host from SCVMM, it may shows the status as “Pending” under VMs and Services / Fabric sections.

If this occurs then the following Microsoft provided fix should be able to help you out (everything done at your own risk naturally).

0) Migrate all VMs off the host to be removed and shutdown host if you haven’t done it before
1) Stop the SCVMM services on the SCVMM server
2) Open SQL Management Studio and attach to the VirtualManagerDB. The name may be different if you modified it during installation.
3) Take a full backup of the database.
4) Right click on the VirtualManagerDB and select New Query
5) Paste the following script in

/*Remove host hardware */
BEGIN TRY
BEGIN TRANSACTION T1

DECLARE @ComputerName AS NVARCHAR(50)
DECLARE @HostID AS NVARCHAR(50)
DECLARE @AgentServerID AS NVARCHAR(50)

/* set variables */
SET @ComputerName = ‘server1.contoso.com‘ /* Insert FQDN of host to be removed here */

SET @HostID =
(
SELECT HostID FROM tbl_ADHC_Host
WHERE ComputerName = @ComputerName
)
SET @AgentServerID =
(
SELECT AgentServerID FROM tbl_ADHC_AgentServerRelation
WHERE HostLibraryServerID = @HostID
)

/*Start removal*/
/* Remove of HBA networking */
DELETE FROM tbl_ADHC_ISCSIHbaToPortalMapping
WHERE ISCSIHbaID in
(
SELECT hbaid FROM tbl_ADHC_HostBusAdapter
WHERE HostID = @HostID
)

DELETE FROM tbl_ADHC_ISCSIHbaToTargetMapping
WHERE ISCSIHbaID in
(
SELECT hbaid FROM tbl_ADHC_HostBusAdapter
WHERE HostID = @HostID
)

DELETE FROM tbl_ADHC_HostInternetSCSIHba
WHERE ISCSIHbaID in
(
SELECT hbaid FROM tbl_ADHC_HostBusAdapter
WHERE HostID = @HostID
)
DELETE FROM tbl_ADHC_FCHbaToFibrePortMapping
WHERE FCHbaID in
(
SELECT HBAId FROM tbl_adhc_HostBusAdapter
WHERE HostID = @HostID
)

DELETE FROM tbl_ADHC_HostFibreChannelHba
WHERE FCHbaID in
(
SELECT HbaID FROM tbl_adhc_HostBusAdapter
WHERE HostID = @HostID
)

DELETE FROM tbl_ADHC_HostSASHba
WHERE SASHbaID in
(
SELECT HBAId FROM tbl_adhc_HostBusAdapter
WHERE HostID = @HostID
)
DELETE FROM tbl_adhc_HostBusAdapter
WHERE HbaID in
(
SELECT HBAId FROM tbl_adhc_HostBusAdapter
WHERE HostID = @HostID
)

/* Remove Host Networking */

DELETE FROM tbl_NetMan_HostNetworkAdapterToLogicalNetwork
WHERE HostNetworkAdapterID in
(
SELECT NetworkAdapterID FROM tbl_ADHC_HostNetworkAdapter
WHERE HostID = @HostID
)
DELETE FROM tbl_ADHC_HostNetworkAdapter
WHERE NetworkAdapterID in
(
SELECT NetworkAdapterID FROM tbl_ADHC_HostNetworkAdapter
WHERE HostID = @HostID
)

/*Remove host hardware */
DELETE FROM tbl_ADHC_VirtualNetwork
WHERE HostID = @HostID
DELETE FROM tbl_ADHC_HostVolume
WHERE HostID = @HostID
Delete FROM tbl_WLC_VDrive
WHERE HostDiskId in
(
SELECT diskid from tbl_ADHC_HostDisk
Where HostID = @HostID
)
DELETE FROM tbl_ADHC_HostDisk
WHERE HostID = @HostID
DELETE FROM tbl_WLC_PhysicalObject
WHERE HostID = @HostID
DELETE FROM tbl_WLC_VObject
WHERE HostID = @HostID

/* Remove references to host */

DELETE FROM tbl_ADHC_HealthMonitor
WHERE AgentServerID in
(
SELECT AgentServerID FROM tbl_ADHC_AgentServerRelation
WHERE HostLibraryServerID = @HostID
)
DELETE FROM tbl_ADHC_AgentServerRelation
WHERE AgentServerID in
(
SELECT AgentServerID FROM tbl_ADHC_AgentServerRelation
WHERE HostLibraryServerID = @HostID
)
DELETE FROM tbl_ADHC_AgentServer
WHERE AgentServerID in
(
SELECT AgentServerID FROM tbl_ADHC_AgentServerRelation
WHERE HostLibraryServerID = @HostID
)

/*Remove physical machine info*/
DELETE from tbl_PMM_PhysicalMachine
WHERE PhysicalMachineID in
(
SELECT PhysicalMachineID from tbl_ADHC_Host
WHERE HostID = @HostID
)

/* Final host removal */
DELETE FROM tbl_ADHC_HostCluster
WHERE AvailableStorageHostID = @HostID
DELETE FROM tbl_NetMan_InstalledVirtualSwitchExtension
WHERE HostID = @HostID
DELETE FROM tbl_RBS_RunAsAccountConsumer
WHERE ObjectID = @HostID
DELETE FROM tbl_VMMigration_EndpointLUNMapping
WHERE EndPointID = @HostID
DELETE FROM tbl_ADHC_HostBusAdapter
WHERE HostID = @HostID
DELETE FROM tbl_ADHC_Host
WHERE HostID = @HostID
DELETE FROM tbl_WLC_VNetworkAdapter
WHERE HostID = @HostID
DELETE FROM tbl_TR_RefresherState
WHERE RefreshRootObjectID = @HostID
COMMIT TRANSACTION T1
END TRY

BEGIN CATCH

IF @@TRANCOUNT > 0
ROLLBACK TRAN T1
END CATCH

6) Change server1.contoso.com to be the FQDN yourserver@yourdomain.com of the server we would like to remove. Make sure to leave the single quotes around the name.

7) Highlight the entire script and click Execute. You should execute teh script twice. On the second time there should be 0 rows affected, if the transaction worked as it should the first time.

8) Exit SQL Management Studio and start the SCVMM services.

9) On VMM Server Run Get-SCVMHost -ComputerName yourserver@yourdomain.com to make sure it is not there. Or you can search for it in VMM admin console

10) Host has been removed successfully

 

If you have any issues, step 3 did recommend that you take a backup of the database and you should restore this database to return you to the starting position if necessary.

Default NetScaler changes

Friday, July 7th, 2017

When deploying a NetScaler, Citrix recommend that you make these changes by default (https://support.citrix.com/article/CTX121149 ).

The Windows Scaling one was particularly useful on a customer site recently where connections over CAG would drop due to window size on the TCP stream not being negotiated with the ASA filrewall correctly. Enable windows scaling and the issue went right away.

Configuring Anti-Virus for VDI

Monday, May 15th, 2017

While this article is specific to Microsoft Defender, it does give good recommendations as to how to configure any vendors A/V for a VDI environment.

https://docs.microsoft.com/en-us/windows/threat-protection/windows-defender-antivirus/deployment-vdi-windows-defender-antivirus

Geo Location Database

Saturday, April 15th, 2017

Need a free geolocation database ? Why not give the guys over at MaxMind a go ?

GeoLite2 Free Downloadable Databases

Powershell launch options

Tuesday, December 29th, 2015

There are a few things that we can do when launching powershell.

1) We can simply start qowrdshell by typing “powershell” at the command prompt.
2) We can launch powershell faster by not displaying the banner – we do this using the command “powershell -nologo”
3) We can launch an older version of powershell by stating which version to launch e.g. “powershell -version 3”
4) We cab launch powershell using a specific configuration fie (e.g. “powershell -psconsolefile my console.psc1”
5) we can launch powrrshell an tell it to run a command on launch – powershell -command “& {get-service}”

System Center Service Accounts

Thursday, December 26th, 2013

There’s a very good list of all of the service accounts required for System Center 2012 at http://systemscentre.blogspot.co.uk/2012/05/system-cennter-2012-service-accounts.html.

Want to know which Active Directory Groups you are a member of ?

Thursday, December 12th, 2013

If you want to know which Active Directory Groups you are a member of and you do not have access to AD, simply open up a command prompt and type

whoami /groups

Nice little trick if you are doing deskside support and want to quickly check that the user is in the right groups

Use PowerShell to sync all Active Directory sites

Thursday, November 28th, 2013

Here’s a quick script for you to synchronise your entire domain

Import-Module ActiveDirectory

$DCs = Get-ADDomainController -Filter *

Foreach ($DC in $DCs) {

$replicate = ‘repadmin /syncall /A /d /e ‘+$DC

iex $replicate

}

Just save it as a ps1 file and run it on any machine with the AD remote server admin tools installed or even a domain controller. If you are delegating rights, delegate them at the root of the domain in Active Dircetory Users and Computers and for each context that you want to replicate in ADSI Edit (see http://www.msresource.net/knowledge_base/articles/how_to:_delegate_the_ability_to_manually_replicate_dcs_using_a_tool_such_as_dssite.msc_or_replmon.html).

if you only want to replicate part of the topology, use the code below:

 

Import-Module ActiveDirectory
$DCs =Get-ADDomainController -Filter *
$Char = [Char]34
$Scope = $Char + ‘DC=Domain,DC=com’ + $Char

Foreach ($DC in $DCs) {
$DC.hostname
$replicate = ‘repadmin /syncall /e ‘ + $DC + ‘ ‘ + $Scope
iex $replicate

}

Want to fully remove a feature ?

Thursday, November 28th, 2013

New to Windows 2012 is the ability to reduce your attack surface further by physically removing binaries from the operating system. Its really quite simple to do. Using the uninstall-windowsfeature command we append the -remove switch and that removes the install binaries from the hard drive.

If you need to add them back then, when using the install-windowsfeature command you will need to add the -source switch and make the installation source available (from a DVD or extracted ISO).

The easiest way to achieve this is to extract the \sources\SxS folder from the install DVD to a file share. The file share will need to be able to be accessed by computer accounts with Read rights. In this way, the features are available for install to any server if they have been removed.

Did I license my server with a MAK key or a KMS key ?

Thursday, November 28th, 2013

Enter the following command to find out:

slmgr /dli