rCisTag-Examples
Add examples to rCisTag module
This commit is contained in:
17
Modules/rCisTag/Examples/01-Get.ps1
Normal file
17
Modules/rCisTag/Examples/01-Get.ps1
Normal file
@@ -0,0 +1,17 @@
|
||||
# Fetch Cis Server hostname and credentials
|
||||
.\CisConfig.ps1
|
||||
|
||||
|
||||
Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd
|
||||
|
||||
# Get Tag information
|
||||
Get-rCisTag
|
||||
|
||||
# Get Tag Category information
|
||||
Get-rCisTagCategory
|
||||
|
||||
# Get Tag Assignment information
|
||||
Get-rCisTagAssignment
|
||||
|
||||
Disconnect-rCisServer -Server $cisServer -Confirm:$false
|
||||
|
||||
14
Modules/rCisTag/Examples/02-New.ps1
Normal file
14
Modules/rCisTag/Examples/02-New.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
# Fetch Cis Server hostname and credentials
|
||||
.\CisConfig.ps1
|
||||
|
||||
Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd
|
||||
|
||||
New-rCisTagCategory -Name MyCat1 -Cardinality Single -Description 'Test Tag Category' -EntityType 'VirtualMachine'
|
||||
New-rCisTag -Name MyTag1 -Category MyCat1 -Description 'Test Tag'
|
||||
$vm = Get-VM | Get-Random
|
||||
New-rCisTagAssignment -Entity $vm -Tag MyTag1
|
||||
|
||||
Get-rCisTagAssignment -Tag MyTag1
|
||||
|
||||
Disconnect-rCisServer -Server $cisServer -Confirm:$false
|
||||
|
||||
11
Modules/rCisTag/Examples/03-Set.ps1
Normal file
11
Modules/rCisTag/Examples/03-Set.ps1
Normal file
@@ -0,0 +1,11 @@
|
||||
# Fetch Cis Server hostname and credentials
|
||||
.\CisConfig.ps1
|
||||
|
||||
Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd
|
||||
|
||||
Get-rCisTag -Name MyTag1 | Set-rCisTag -Name MyNewTag1 -Description 'Name changed'
|
||||
|
||||
Get-rCisTagCategory -Name MyCat1 | Set-rCisTagCategory -Cardinality Multiple -Name MyNewCat1 -Description 'Name changed'
|
||||
|
||||
Disconnect-rCisServer -Server $cisServer -Confirm:$false
|
||||
|
||||
13
Modules/rCisTag/Examples/04-Remove.ps1
Normal file
13
Modules/rCisTag/Examples/04-Remove.ps1
Normal file
@@ -0,0 +1,13 @@
|
||||
# Fetch Cis Server hostname and credentials
|
||||
.\CisConfig.ps1
|
||||
|
||||
Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd
|
||||
|
||||
Get-rCisTagAssignment -Tag MyNewTag1 | Remove-rCisTagAssignment -Confirm:$false
|
||||
|
||||
Get-rCisTag -Name MyNewTag1 | Remove-rCisTag -Confirm:$false
|
||||
|
||||
Get-rCisTagCategory -Name MyNewCat1 | Remove-rCisTagCategory -Confirm:$false
|
||||
|
||||
Disconnect-rCisServer -Server $cisServer -Confirm:$false
|
||||
|
||||
20
Modules/rCisTag/Examples/05-Tag-Datastore.ps1
Normal file
20
Modules/rCisTag/Examples/05-Tag-Datastore.ps1
Normal file
@@ -0,0 +1,20 @@
|
||||
# Fetch Cis Server hostname and credentials
|
||||
.\CisConfig.ps1
|
||||
|
||||
Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd
|
||||
|
||||
$catName = 'Homelab'
|
||||
|
||||
# Clean up
|
||||
Get-rCisTagCategory -Name $catName | Remove-rCisTagCategory -Confirm:$false
|
||||
|
||||
# Tag all datastores with their type
|
||||
New-rCisTagCategory -Name HomeLab -Description 'Homelab datastores' -Cardinality Single -EntityType 'Datastore' |
|
||||
New-rCisTag -Name 'VMFS','NFS' -Description 'Datastore type'
|
||||
|
||||
Get-Cluster -Name Cluster1 | Get-Datastore | %{
|
||||
New-rCisTagAssignment -Entity $_ -Tag "$($_.Type)"
|
||||
}
|
||||
|
||||
Disconnect-rCisServer -Server $cisServer -Confirm:$false
|
||||
|
||||
3
Modules/rCisTag/Examples/CisConfig.ps1
Normal file
3
Modules/rCisTag/Examples/CisConfig.ps1
Normal file
@@ -0,0 +1,3 @@
|
||||
$cisServer = 'vcsa.my.domain'
|
||||
$cisUser = 'administrator@vsphere.local'
|
||||
$cisPswd = 'VMware1!'
|
||||
Reference in New Issue
Block a user