Posts

Showing posts from January, 2021

PowerShell - Pass Dynamic Arguments from Function to Function

If you are interested in passing dynamic arguments from function to function in PowerShell, I think the following will help you out: Create the function(s) like this function MyFunction1 { [CmdletBinding()] param ( [string]$requiredParm1, [string]$requiredParm2, [parameter(ValueFromRemainingArguments=$True)] $dynamicArgs ) $props = @() if($dynamicArgs) { $num = 0 for ($num = 0; $num -lt $dynamicArgs.Count; $num = $num + 2) { $format_string = (([string]$dynamicArgs[$num]) + " '" + [string]$dynamicArgs[$num+1] + "' ``") $props += $format_string } } $string_props = $($props | Out-String) $second_function = "MyFunction2 -requiredParm1 $requiredParm1 " $second_function += "-requiredParm2 $requiredParm2 " $second_function += "$string_props;" Invoke-Expression $second_function } function MyFunction2 { [CmdletBinding()] param ( [st

Ansible Module - VMWare Update Guest PCI Device

Ansible Module to enable PCI Passthrough for a VM after the Host Device is configured for Passthrough . #!/usr/bin/env python ANSIBLE_METADATA = { 'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community' } DOCUMENTATION = ''' --- module: vmware_update_guest_pci_device short_description: Module to update PCI Passthrough device for a guest version_added: "2.4" description: - "Module to update PCI Passthrough device for a guest, based on device_name or device_id" options: hostname: description: - vSphere service to connect to required: true username: description: - username to connect to vSphere hostname required: true password: description: - username password required: true esxi_hostname: desciption: - Esxi host to make changes to device_name:

Ansible Module - VMWare Update Host PCI Passthrough

Ansible Module to enable PCI Passthrough for a Device on VMWare Host. #!/usr/bin/env python ANSIBLE_METADATA = { 'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community' } DOCUMENTATION = ''' --- module: vmware_update_host_pci_passthrough short_description: Module to update PCI Passthrough device for a host version_added: \"2.4\" description: - \"Module to update PCI Passthrough device for a host, based on device_name or device_id\" options: hostname: description: - vSphere service to connect to required: true username: description: - username to connect to vSphere hostname required: true password: description: - username password required: true esxi_hostname: description: - Esxi host to make changes to device_name: description: