{"id":3165,"date":"2020-08-07T22:50:26","date_gmt":"2020-08-07T20:50:26","guid":{"rendered":"https:\/\/www.mariotti.de\/?p=3165"},"modified":"2020-08-07T22:50:26","modified_gmt":"2020-08-07T20:50:26","slug":"powershell-beispiele-zu-den-citrix-provisioning-services-cmdlets","status":"publish","type":"post","link":"https:\/\/dev.mariotti.de\/?p=3165","title":{"rendered":"PowerShell Beispiele zu den Citrix Provisioning Services Cmdlets"},"content":{"rendered":"<p>Einige einfache Beispiele zu den PowerShell Cmdlets der Citrix Provisioning Services<\/p>\n<pre><code class=\"language-powershell\"># https:\/\/developer-docs.citrix.com\/projects\/provisioning-services-powershell-object-programming-guide\/en\/latest\/#start-pvscreatedisk\n\n# Registry module\nSet-Location \"C:\\Program Files\\Citrix\\Provisioning Services Console\"\nC:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\installutil.exe Citrix.PVS.SnapIn.dll\n\n# Import module\nImport-Module \"C:\\Program Files\\Citrix\\Provisioning Services Console\\Citrix.PVS.SnapIn.dll\"\n\n# List all vDisks off all sites\n(Get-PvsDiskLocator).Name\n\n# List of vDisks on a specific PVS server\n(Get-PvsDiskLocator -ServerName 'W2K16PVS01').Name\n\n# Test if a specific vDisk exists\nif ((Get-PvsDiskLocator).Name -eq \"MyDisk1\") { write-host \"vDisk found\"}\n\n# List all devices with all details\nGet-PvsDevice \n\n# List all devices with some specific params\nGet-PvsDevice | Select-Object Name,DeviceMAC,BootFrom,Active\n\n# List details of a specific device\nGet-PvsDevice -DeviceName 'PVSTARGET01'\n\n# List assigned disks of a specific device\n(Get-PvsDiskLocator -DeviceName 'PVSTARGET01').Name\n\n# Remove a specific disk assignments from a specific device\nRemove-PvsDiskLocatorFromDevice -DeviceName 'PVSTARGET01' -DiskLocatorName 'MyDisk1' -SiteName 'Site' -StoreName 'Store'\n\n# Remove ALL disk assignments from a specific device\n$Disks = (Get-PvsDiskLocator -DeviceName 'PVSTARGET01')\nforeach ($Disk in $Disks)\n{\n    Write-host \"Removing disk $($Disk.name) from device\"\n    Get-PvsDevice -Name 'PVSTARGET01' -Fields Guid | Remove-PvsDiskLocatorFromDevice -Name $Disk.DiskLocatorName -SiteName 'Site' -StoreName 'Store'\n}\n\n# Assign a disk to device\nAdd-PvsDiskLocatorToDevice -Name 'MyDisk1' -DeviceName 'PVSTARGET01' -SiteName 'Site' -StoreName 'Store'\n\n# Create a new empty vdisk\nStart-PvsCreateDisk -Name \"MyDisk1\" -Description \"MyDescription1\" -SiteName \"Site\" -StoreName \"Store\" -ServerName \"W2K16PVS01\" -Size 40000 -VHDX\n\n# Change Disk mode (Note: WriteCacheType: 0 (Private), (other values are standard image) 1 (Cache on Server), 3 (Cache in Device RAM), 4 (Cache on Device Hard Disk), 6 (Device RAM Disk), 7 (Cache on Server, Persistent), or 9 (Cache in Device RAM with Overflow on Hard Disk).\nSet-PvsDisk -Name 'MyDisk1' -StoreName 'Store' -SiteName 'Site' -WriteCacheType 9 -WriteCacheSize 512\n\n# Create a new disk version\nNew-PvsDiskMaintenanceVersion -DiskLocatorName 'MyDisk1' -StoreName 'Store' -SiteName 'Site'\n\n# Commit the changes made in the current Maintenance or a Test version. Promotes the Maintenance version or a Test version to a Testor new Production \nInvoke-PvsPromoteDiskVersion -DiskLocatorName 'MyDisk1' -StoreName 'Store' -SiteName 'Site' # Promote disk version (PRODUCTION)\nInvoke-PvsPromoteDiskVersion -DiskLocatorName 'MyDisk1' -StoreName 'Store' -SiteName 'Site'  -Test # Promote disk version (TEST)\n\n# Connect via PS Remoting from the golden master target system to the PVS server and create a new empty disk and assign this disk in preperation for a later image capture to this disk\n$CredObject = New-Object System.Management.Automation.PsCredential(\"ServiceAccount@test.local\", (ConvertTo-SecureString \"Passw0rd\" -AsPlainText -Force))\nInvoke-Command -ComputerName \"W2K16PVS01.test.local\" -Credential $CredObject -ScriptBlock {\n\n    # Import module    \n    Set-Location \"C:\\Program Files\\Citrix\\Provisioning Services Console\"\n    C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\installutil.exe Citrix.PVS.SnapIn.dll\n    Import-Module \"C:\\Program Files\\Citrix\\Provisioning Services Console\\Citrix.PVS.SnapIn.dll\"\n\n    # Generate empty vDisk\n    Start-PvsCreateDisk -Name \"MyDiskName\" -Description \"MyDisk\" -SiteName \"Site\" -StoreName \"Store\" -ServerName \"W2K16PVS01\" -Size 40000 -VHDX\n\n    # Assign disk to device\n    Add-PvsDiskLocatorToDevice -Name \"MyDiskName\" -DeviceName \"PVSTARGET01\" -SiteName \"Site\" -StoreName \"Store\"\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Einige einfacherer Beispiele zu den PowerShell Cmdlets der Citrix Provisioning Services<\/p>\n","protected":false},"author":2,"featured_media":2347,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35,37],"tags":[],"class_list":["post-3165","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-citrix","category-powershell"],"_links":{"self":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts\/3165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3165"}],"version-history":[{"count":0,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts\/3165\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/media\/2347"}],"wp:attachment":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}