vRops – suite-api – createReport & downloadReport

So I needed to automatically run an oversized VM report on a few vRops environments and combine them into one report.

This isn’t my full script as I take the csv and combine is with other data from other metadata, database..etc… but hopefully the following example script / function might help you… It executes the report via the suite-api, waits for it to finish and downloads the csv to a local folder.

First things first… update line 15 in the example script below with your own vRops server IP or FQDN.

PowerShell

1

$vRopsAddress='vc.vman.local'

So that I don’t keep being prompted for credentials I save the service account user and password with the powershell Get-Credential command.

PowerShell

1

2

$cred=Get-Credential

$cred|Export-Clixml-Path"d:\vRops\Config\vc.xml"

Once you have generated the XML update line 16 to reflect your *.XML file

PowerShell

1

$vRopsCreds=Import-Clixml-Path"$ScriptPath\config\VC.xml"

Now that we got that out of the way… we need to obtain the ResourceID for the object / level we wish to run the report for, in my case i want to run it for the whole VC so the easiest way to find the ResourceID for the VC is to use the vRops GUI, search for the VC and get the ResourceID from the URL.

Go to line 17 in the code below and update it to match your ResourceID

PowerShell

1

$vCenter='7d3a8453-6559-4d4c-9005-3f8655e4394f'

Now we need to do something similar for the Report that the script will run… So in the vRops GUI, navigate to Content, Reports, Click on Generated Reports

Once you click on Generated Reports you will notice that the URL now has an ID for the Report

Go to line 18 in the code below and update it to match the Report ID

PowerShell

1

$Report='1f69952f-7ff4-4d2c-9446-81a811de19b0'

if you found this post useful please consider checking out one of the sponsored links to keep the site running…

full script below…

PowerShell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

<#

The following command must be run once to generate the Credential file to connect to each environment.

Related

5 Comments

Amol
on 25/09/2017 at 17:48

I have tried this scrip on vROps 6.6 and i am facing problem in downloading report. URI for report to be downloaded is giving “HTTP 404” error. The “$ReportLinkurl” variable is not getting updated with proper report path.