Hi,
I am trying to run the script for srm configurations to pull the srm details,but its throws error.
PowerCLI C:\temp> .\srm.ps1
At C:\temp\srm.ps1:2 char:24
+ Function Get-SrmConfig {
+ ~
Missing closing '}' in statement block.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingEndCurlyBrace
I have attached the script.Any help will be appreciated.
thanks
vm2014
Mike,
Thanks for your all hard effort.Does this cmd let "
##### Disconnecting...
$srm01.SRMLogout($srmApi01)
is disconnecting my Vcenter after showing
Connected to SRM mxxxxxxx.ya.corp.kkll.com
Exporting recovery plans...
Row count: 46
Name State ProtectionGroupNames
---- ----- --------------------
SRM_Qualy SRDF # 130 protecting SRM_Qualy SRD...
SRM_Qualy SRDF # 131 protecting SRM_Qualy SR...
SRM_Qualye SRDF # 135 protecting SRM_Qualy SRD...
SRM_Qualy SRDF # 136 protecting SRM_Qualy SRD...
thanks
vm2014.
Yes, I've noticed that it's best to close PowerCLI after running this script. It's using that API call to log in and out of the SRM server, instead of the equivalent "Connect-SrmServer" commands. I always have problems with any other scripts after running this one, even if I manually re-connect to my vCenter. So now I just close and re-open PowerCLI.
Mike,
Could you please explain briefly how to fix this.Right now the script is fine now.
thanks
vm2014
vmk2014 wrote:
Mike,
Could you please explain briefly how to fix this.Right now the script is fine now.
How to fix what? That you are getting disconnected from your vCenter in the middle of running this script? Here's what works for me: I connect to my vCenter (actually, in my case, I connect to my vCenter in my Powershell profile, so every time I start PowerCLI, I am automatically connected to my vCenter. Then I run that script. Since the connections seem to become unstable after running the script, I just close PowerCLI when I am done running that one script, and re-open PowerCLI.
I have found that if I am not connected to my vCenter, I get those same errors you posted - the underlying connection connection was closed, etc. By making sure I am connected to a vCenter first, I don't get those errors, and the script eventually completes all it's sections.
Mike,
Thanks.I tried the same way by creating powershell profile
Getting Started with PowerCLI 5.1 and PowerShell 3.0 | Virten.net
but it always stops at protected Data store after displaying few lines.So its disconnects its seems even though i kept my power shell profile open.
Currently i can get only Recovery plan,protected group and data store(incomplete).
thanks
vm2014
Mike,
what are the out put you are getting from this script? like DS,Recovery plan etc. Still after connecting power shell profile its disconnect vcenter server
thanks
vm2014.
Mike,
Just to confirm once.
First 1) Connect power shell profile
2) Connect vsphere Power cli
3) Call function srm.ps1,Get-srm-config.ps1
4)Get-SrmConfig -SrmServerAddr srm server name User name -Password
thanks
vm2014
Mike,
Please help me on for getting replicated DS,Inventory mappings and protected VMs list.Others i am getting the output.Its disconnect after showing the first 3 output.
thanks
vm2014
I get:
Exporting recovery plans...
Row count: 24
Name State ProtectionGroupNames
---- ----- --------------------
1-PHA_WilsonParkSite_Recovery protecting EMC_LUN_18, EMC_LUN_19, EMC_LUN_20, EMC_LUN_21, EMC_LUN_23, EMC_LUN_22, EMC_LUN_01, EMC_LUN_02, EMC_LUN_03, EMC_LUN...
EMC_LUN_01_Recovery protecting EMC_LUN_01
Exporting protection groups...
Row count: 23
Name Type State PeerState
---- ---- ----- ---------
EMC_LUN_01 san ready shadowing
Exporting protected datastores...
Row count: 23
Id Name Uid CapacityMB Path ProtectionGroup
-- ---- --- ---------- ---- ---------------
Datastore-datastore-7596 EMC_DS_01 1,048,320 Datacenters/Wilson Park Datacenter/datastore/EMC_DS_01 EMC_LUN_01
Datastore-datastore-7592 EMC_DS_02 1,048,320 Datacenters/Wilson Park Datacenter/datastore/EMC_DS_02 EMC_LUN_02
Exporting VMs...
Row count: 144
Id Name ProtectionGroupName ProtectedVmId PeerProtectedVmId Status
-- ---- ------------------- ------------- ----------------- ------
VirtualMachine-vm-1717 ADMNAPP005 EMC_LUN_16 protected-vm-9582 protected-vm-11072 isProtected
Exporting replicated datastores...
Row count: 2
Id Name Uid CapacityMB
-- ---- --- ----------
Datastore-datastore-6803 EMC_DS_101 /VIServer=pha.phila.gov\leonem@dctrvmw002.wrk.ads.pha.phila.gov:443/Datastore=Datastore-datastore-6803/ 511744
Datastore-datastore-6791 EMC_TEMPLATES_DS_01 /VIServer=pha.phila.gov\leonem@dctrvmw002.wrk.ads.pha.phila.gov:443/Datastore=Datastore-datastore-6791/ 511744
Exporting inventory mappings...
Row count: 8
Id Name Type Path
-- ---- ---- ----
ResourcePool-resgroup-5384 Resources ResourcePool Datacenters/Wilson Park Datacenter/host/PHA WP DataCenter Cluster/Resources
Folder-group-v7139 Test Folder Datacenters/Wilson Park Datacenter/vm/Test
Well, you don't "connect" the profile, it loads when PowerCLI (actually Powershell) starts. I just start up PowerCLI, connect to my vCenter, load the function, then call it.
You are connecting to a vCenter first, right? Using a "Connect-VIServer" command before you call the "Get-SrmConfig" function?
- You don't need step 1 (starting PowerShell). PowerCLI is a "front end" of sorts to PowerShell. So just start PowerCLI.
- You say your Powershell profile automatically connects you to your vCenter server? So your profile has the "Connect-VIServer" command in it?
What does your profile look like? Do a "notepad $profile" to see what's in there, and show us what's in there.
- You don't need step 3 (connect to the SRM server), as the function does that. Skip this step.
- In step 4, you made those changes to the script that I posted about earlier, right?
So you're saying the script says you should have 46 recovery plans, but then stops (with no error message) after listing only the first 3 plans? At the very least, it should show you all the plans, as the script gathers all plan information first, before then showing all the plans at once.
It never gets to the next section, about exporting protection groups? Or any further than that?
One other thing you can try:
> $VerbosePreference="Continue"
> Write-Verbose "TEST"
This will output: VERBOSE: TEST
Do that before step 5 (the "Get-SrmConfig ..."). It will give a lot of output as each command in "Get-SrmConfig" executes.
VERBOSE: 9/11/2014 11:46:00 AM Get-Datastore Started execution
VERBOSE: 9/11/2014 11:46:02 AM Get-Datastore Finished execution
VERBOSE: 9/11/2014 11:46:02 AM Get-View Started execution
VERBOSE: 9/11/2014 11:46:02 AM Get-View Finished execution
Maybe that will give you more information as to where in the process things stop, and why ...
1. Do you use vSphere replication? I don't, and had to comment out the calls to vSphere replication listings.
2. You didn't make the changes to the script that I posted.
In the section about exporting VMs (around line 200 or so), this returns no output:
$vmID = $protVMInfo.vm.value
$vmObj = Get-VM -Id “*$vmID”
But if I change it to:
$vmID = “VirtualMachine-” + $protVMInfo.vm.value
$vmObj = Get-VM -Id “$vmID”
Then it works, and returns the VM name and Protection Group.
I have a VirtualApp installed on my protected site that is not mapped to my recovery site. This causes the InventoryMapping to fail, as the lookup into mapped objects returns null. I added:
$poolType = $mapPool.type
IF ($poolType -ne “VirtualApp”)
And then it was able to finish. I had to do similar with the ResourcePool section - adding "ResourcePool-" to the "mapPool", else the "Get-VIHumanReadablePath" fails, because you are passing a managed object that doesn't link to anything.
I think that your problems are caused by the script not accounting for all possible values, that is, not doing comprehensive error checking for different possible values. It failed for me, until I made the above changes.
Mike,
Thanks for making corrections.I added the following lines on the basis of your recommendations 2.
1.) Do you use vSphere replication? I don't, and had to comment out the calls to vSphere replication listings.
Answer : - No, we use array based replications i.e SRDF.
2)You didn't make the changes to the script that I posted. - Done
$vmID = “VirtualMachine-” + $protVMInfo.vm.value
$vmObj = Get-VM -Id “$vmID”
VERBOSE: 9/11/2014 9:46:18 PM Get-View Finished execution
VERBOSE: 9/11/2014 9:46:18 PM Get-View Started execution
VERBOSE: 9/11/2014 9:46:19 PM Get-View Finished execution
VERBOSE: 9/11/2014 9:46:19 PM Get-View Started execution
VERBOSE: 9/11/2014 9:46:19 PM Get-View Finished execution
VERBOSE: 9/11/2014 9:46:19 PM Get-View Started execution
VERBOSE: 9/11/2014 9:46:20 PM Get-View Finished execution
VERBOSE: 9/11/2014 9:46:22 PM Get-Datastore Started execution
Get-Datastore : 9/11/2014 9:46:28 PM Get-Datastore The underlyi
connection was closed: An unexpected error occurred on a receive.
At C:\temp\srm.ps1:154 char:23
+ $protDatastoreObj = Get-Datastore | Where {$_.id -like
"*$datastoreID"}
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Datastore], ViError
+ FullyQualifiedErrorId : Client20_QueryServiceImpl_ContinueRetrieveP
tiesEx_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetDatasto
VERBOSE: 9/11/2014 9:49:08 PM Get-Datastore Started execution
VERBOSE: 9/11/2014 9:49:14 PM Get-Datastore Finished execution
VERBOSE: 9/11/2014 9:49:14 PM Get-View Started execution
VERBOSE: 9/11/2014 9:49:14 PM Get-View Finished execution
VERBOSE: 9/11/2014 9:49:14 PM Get-View Started execution
VERBOSE: 9/11/2014 9:49:15 PM Get-View Finished execution
VERBOSE: 9/11/2014 9:49:15 PM Get-View Started execution
VERBOSE: 9/11/2014 9:49:15 PM Get-View Finished execution
VERBOSE: 9/11/2014 9:49:15 PM Get-View Started execution
VERBOSE: 9/11/2014 9:49:16 PM Get-View Finished execution
VERBOSE: 9/11/2014 9:49:16 PM Get-Datastore Started execution
Its stops here
3) Yes we have resource pools mapping.
thanks
vm2014
Mike,
Finally it worked. Thanks for your support.Thanks!! Now i need to validate it.
Thanks
vm2014
Glad I could help, and that it's now working for you.