citrix / Powershell-Scripts

Repository of useful powershell scripts related to Citrix
45 stars 25 forks source link

intrasite rep with mor than 1 store is not working #2

Open sun3047 opened 7 years ago

sun3047 commented 7 years ago

I tried to use the Script for an Intrasite replication. However, it is not working and will cancel with the following Output: Get-PvsStore : Cannot bind parameter 'StoreId'. Cannot convert value "System.Object[]" to type "System.Guid". Error: "Guid should contain 32 digits with 4 dashes

In my case, this line returns more than one store back and this is not supported $IS_storeID = (Get-PvsServerStore -ServerName $IS_srcServer.Split('.')[0]).StoreID[0].ToString()

ryanchauvin commented 6 years ago

I'm having the same issue

Andymannen commented 6 years ago

Exactly the same problem here...

korbinianthiel commented 6 years ago

I fixed this issue with only small code changes:

$IS_storeIDs = (Get-PvsServerStore -ServerName $IS_srcServer.Split('.')[0]).StoreID
foreach ($IS_StoreID in $IS_StoreIDs) {
    ...
}
tjglaser1s commented 6 years ago

Hello...first I apologize because I'm a complete powershell novice. I copied your line into the v2 script and replaced line 410/411. I get an error that says "..." is not is not the name of a cmdlet. image

korbinianthiel commented 6 years ago

"..." was only a placeholder for the code ;) Here is the full version:

$IS_storeIDs = (Get-PvsServerStore -ServerName $IS_srcServer.Split('.')[0]).StoreID
foreach ($IS_StoreID in $IS_StoreIDs) {
    $IS_storePath = (Get-PvsStore -StoreId $IS_storeID).Path
    $IS_dstServers = @()
    foreach($s in (Get-PvsServer -SiteName $IS_site.SiteName | Select-Object -ExpandProperty ServerFQDN)){
    if($s -notlike $IS_srcServer){
        $IS_dstServers += $s
        }
    }
    ##CHECK VDISKS
    if($vDisksToExport.Length -ne 0){
        $exportMsg = Validate-ExportList -server $srcServer -list $vDisksToExport
        if($exportMsg -notlike ""){
                Write-Host $exportMSG -BackgroundColor Black -ForegroundColor Red
                $exportMsg += ".  Script Terminated."
                Write-EventLog -LogName Application -Source $replication -EventId 5 -EntryType Error -Message $exportMsg -Category 0
                exit
        }
    }
    else{
        $exportMsg = "No list of vDisks to export found.  Exporting ALL vDisks found on $IS_srcServer."
        Write-EventLog -LogName Application -Source $replication -EventId 6 -EntryType Warning -Message $exportMsg -Category 0
        $IS_vDisksToExport = Get-PvsDiskLocator -StoreID $IS_StoreID -SiteName $IS_Site.SiteName | Select-Object -ExpandProperty DiskLocatorName
    }
    $IS_StorePath = $IS_StorePath -replace ':','$'
    $IS_srcPath = "\\$IS_srcServer\$IS_StorePath"
    $cred = Get-Credential
    foreach($s in $IS_dstServers){
        $IS_dstPath = "\\$s\$IS_StorePath"
        foreach($vdisk in $IS_vDisksToExport){
            Start-ISRobocopy -server $s -srcPath $IS_srcPath -dstPath $IS_dstPath -disk $vdisk -cred $cred -eventLog $replication
        }
    }
    Wait-Job -State Running
    Write-Host DONE
}

Would be nice if you can give a short feedback if it also works for you. If so I will make a pull request.

tjglaser1s commented 6 years ago

Well the error is gone but I still can't get the vdisk to replicate. It's like the robocopy just isn't moving the files. I can go FROM farm1/server1 TO farm2/server1 but I can't go FROM farm2/server1 TO farm1/server1.