Forum Discussion

doctordns's avatar
doctordns
Brass Contributor
Aug 06, 2022

Test-SRTopology fails with an error message using PowertShell

Background:

2 servers (SRV1, SRV2)

Both have two disks with a T: volume and a G: volume. The former is the replication source.target and G: is the log file disk.

I successfully create the SR partnership, like this: (Using PowerShell 7!)

PS C:\Foo> # 14. Creating an SR replica partnership
PS C:\Foo> $NewSRHT =  @{
>>   SourceComputerName       = 'SRV1'
>>   SourceRGName             = 'SRV1RG1'
>>   SourceVolumeName         = 'S:'
>>   SourceLogVolumeName      = 'G:'
>>   DestinationComputerName  = 'SRV2'
>>   DestinationRGName        = 'SRV2RG1'
>>   DestinationVolumeName    = 'S:'
>>   DestinationLogVolumeName = 'G:'
>>   LogSizeInBytes           = 2gb
>> }
PS C:\Foo> New-SRPartnership @NewSRHT

RunspaceId              : 07a43e6e-05e1-4dc1-9559-281cb66ca541
DestinationComputerName : SRV2
DestinationRGName       : SRV2RG1
Id                      : 19e164bd-67f0-4b65-99ec-c7de97bb6731
SourceComputerName      : SRV1
SourceRGName            : SRV1RG1

 As you can see the partnership is created.

However when I run the Test-SRTopology, i get an error message that is not actionale:

PS C:\Foo> # 15. Testing the SR Topology
PS C:\Foo> $TestSRHT =  @{
>>   SourceComputerName       = 'SRV1'
>>   SourceVolumeName         = 'S:'
>>   SourceLogVolumeName      = 'G:'
>>   DestinationComputerName  = 'SRV2'
>>   DestinationVolumeName    = 'S:'
>>   DestinationLogVolumeName = 'G:'
>>   DurationInMinutes        = 1
>>   ResultPath               = 'C:\Foo\'
>>   Verbose = $True
>> }
PS C:\Foo> Test-SRTopology @TestSRHT
WARNING: Specified cast is not valid.
WARNING: System.InvalidCastException
WARNING:    at Microsoft.FileServices.SR.Powershell.MSFTVolume.get_FileSystemType()
   at Microsoft.FileServices.SR.Powershell.Volume.GetVolume(String Path, String ComputerName)
   at Microsoft.FileServices.SR.Powershell.TestSRTopologyCommand.BeginProcessing()
Test-SRTopology: Specified cast is not valid.

What does "Specified cast is not valid" actually mean and how do I resolve it?:

 

  • Mohammed911's avatar
    Mohammed911
    Copper Contributor

    I have the same issue crated a test lab, where I have 2 servers both are DCs, well connected. After I finished configuring Storage Replica I run the command Test-SRTopology and I get an error.

    below is the first error when I use the name of both servers:

     

    PS C:\Users\Administrator> Test-SRTopology -SourceComputerName NYC-DC1 -SourceVolumeName R: -SourceLogVolumeName L: -DestinationComputerName NYC-SVR1.ABC.com -DestinationVolumeName R: -DestinationLogVolumeName L: -DurationInMinutes 5 -ResultPath C:\results\

     

    WARNING: WMI v2.0 could not create a CIM Session for NYC-DC1 Possible reasons are:
    You specified an incorrect NetBIOS name or fully qualified domain name for the destination computer
    You specified an IP address for the destination server. Only NetBIOS names or fully qualified domain names are allowed
    The destination computer firewall is blocking access to PowerShell or WMI remoting
    You are logged on to the source computer as a local user. You must use a domain user
    You did not use CREDSSP credentials when running the Test-SRTopology cmdlet remotely from a management computer
    The destination computer is not running or is not accessible over the network
    The destination computer is not running the WMI service
    WARNING: System.Exception
    WARNING: at Microsoft.FileServices.SR.Powershell.MIConnection.GetNamespace(String namespaceName, String computerName)
    at Microsoft.FileServices.SR.Powershell.TestSRTopologyCommand.GetNetBiosName(String ComputerName)
    at Microsoft.FileServices.SR.Powershell.TestSRTopologyCommand.BeginProcessing()
    Test-SRTopology : WMI v2.0 could not create a CIM Session for NYC-DC1
    Possible reasons are:
    You specified an incorrect NetBIOS name or fully qualified domain name for the destination computer
    You specified an IP address for the destination server. Only NetBIOS names or fully qualified domain names are allowed
    The destination computer firewall is blocking access to PowerShell or WMI remoting
    You are logged on to the source computer as a local user. You must use a domain user
    You did not use CREDSSP credentials when running the Test-SRTopology cmdlet remotely from a management computer
    The destination computer is not running or is not accessible over the network
    The destination computer is not running the WMI service
    At line:1 char:1
    + Test-SRTopology -SourceComputerName NYC-DC1 -SourceVolumeName R: -Sou ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Test-SRTopology], Exception
    + FullyQualifiedErrorId : TestSRTopologyFailure,Microsoft.FileServices.SR.Powershell.TestSRTopologyCommand

     

    The second error when I use fully qualified name of both servers:

     

    PS C:\Users\Administrator> Test-SRTopology -SourceComputerName NYC-DC01.ABC.com -SourceVolumeName R: -SourceLogVolumeName L: -DestinationComputerName NYC-SVR1.ABC.com -DestinationVolumeName R: -DestinationLogVolumeName L: -DurationInMinutes 5 -ResultPath C:\results\
    WARNING: Specified cast is not valid.
    WARNING: System.InvalidCastException
    WARNING: at Microsoft.FileServices.SR.Powershell.MSFTVolume.get_FileSystemType()
    at Microsoft.FileServices.SR.Powershell.Volume.GetVolume(String Path, String ComputerName)
    at Microsoft.FileServices.SR.Powershell.TestSRTopologyCommand.BeginProcessing()
    Test-SRTopology : Specified cast is not valid.
    At line:1 char:1
    + Test-SRTopology -SourceComputerName NYC-DC01.ABC.com -SourceVolumeNam ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Test-SRTopology], InvalidCastException
    + FullyQualifiedErrorId : TestSRTopologyFailure,Microsoft.FileServices.SR.Powershell.TestSRTopologyCommand

    doctordns 

    • NortheR73's avatar
      NortheR73
      Copper Contributor

      Mohammed911 

      Disabling IPv6 network adapter binding should help:

      Disable-NetAdapterBinding -Name 'Ethernet' -ComponentID 'ms_tcpip6'
    • Thomas Lee's avatar
      Thomas Lee
      Brass Contributor
      I spent some time over this and have had no success.
      The script I ran (subset shown abovce) has worked in the past. But now it doesn;t work in PowerSHell7 or Windows PowerShell.
      I have filed a feedback item but since I suspect with so few folsk have hit this issue, this issue hasn';t risen to a level where investigation is undertaken.

      I had planned to use this cmdlet in my lstest book on PowerShell and Windows Server 2022. But as it fails, I removed it. and described this cmdlet as non-functioning.

      Like so many, many places, Microsoft seem to have abandoned Windows Server on Prem in their push to the cloud. There are many minor places where IT Pros could benefit frtom some improvements (like enabling ther BPA, WSUS, cmdlets to run in PowerShell 7).

      I just gave up on a fix and have moved on,. From my testing, even though this cmdlet fails, the SR partnership works a treat. A great feature!

Resources