[英]Hardening VM-HOST Set-AdvancedSetting with PowerCLI from csv file
我想自動配置第一個主機,以使用PowerCLI創建主機配置文件。 我在ESXi 6.5中構建了第一個HOST,並從該HOST中獲得了第一個主機配置文件。 但是要創建第一個主機配置文件,我逐行進行了一個“編輯主機配置文件”,這花費了很長時間。 我們有60多個不同的集群,這意味着我必須為每個集群創建一個主機配置文件。
我通過此行從第一台主機使用PowerCLI進行了導出
Get-AdvancedSetting -Entity $HOST65 | Export-Csv -Path T:\_Evergreening_\Script\$clHOSTprofile-config.csv -NoTypeInformation
我在csv文件中獲得了此文件(標題)
Uid Value Description Type Entity Id Name Client
我將使用“名稱和值”列的CSV文件進行Set-AdvancedSetting
Get-AdvancedSetting -Entity $HOST65 -Name 'from_csv_file' | Set-AdvancedSetting -Value 'from_csv_file'
我不確定如何設置...
結帳“導入Csv”
您可以執行以下操作:
# Obtain and export Advanced Settings from a specified host Get-AdvancedSetting -Entity $HOST65 | Export-Csv -Path T:\_Evergreening_\Script\$clHOSTprofile-config.csv -NoTypeInformation # Import CSV file into a PowerShell array object $csvInputs = Import-Csv -Path T:\_Evergreening_\Script\$clHOSTprofile-config.csv # Create a loop to address each item of the array, sourcedfrom the CSV foreach ($csvInput in $csvInputs) { # Obtain and set the individual advanced setting on a specified host Get-AdvancedSetting -Entity $HOST6502 -Name $csvInput.Name | Set-AdvancedSetting -Value $csvInput.Value }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.