簡體   English   中英

使用 Plink 更新 vCenter 登錄橫幅標題僅顯示第一個單詞

[英]Using Plink to update vCenter Logon banner title only displays the first word

我正在自動化基線配置過程,以包括 ESXi 和 vCenter 服務器的 DISA STIG。 我遇到問題的部分是更新登錄橫幅的標題,特別是,一旦代碼到達第一個空格,它就會轉儲標題的其余部分。 例如,目標是顯示“DoD 用戶協議”,但是,在運行腳本后它只顯示“DoD”。 如果我輸入“DoD_User_Agreement”,它會顯示整個字符串。 如何讓它顯示帶有空格的標題? 如果我通過 SSH 終端或本地運行命令,它會正確運行。

這是代碼片段,V-243117 變量是包含特定命令行的行:

$ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($VICred.Password)
$plinkpw = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($ptr)
[System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($ptr)

#Create a line break 
$echonl = "echo -e "" >> /etc/vmware/vsphere-ui/webclient.properties;"

#Enter Shell Mode
$Mode = "shell"

# V-243073
$V243073 = "echo -e `"refresh.rate = -1`" >> /etc/vmware/vsphere-ui/webclient.properties;" 

# V-243075
$V243075 = "sed -i '\''s/.*session\\\\.timeout.*/session.timeout = 10/'\'' /etc/vmware/vsphere-ui/webclient.properties;"

# V-243093
$V243093 = "echo -e `"show.allusers.tasks = true`" >> /etc/vmware/vsphere-ui/webclient.properties;"

# V-243117
$banner_array = @(
    "You are accessing a U.S. Government \\\\(USG\\\\) Information System \\\\(IS\\\\) that is provided for USG-authorized use only.
    By using this IS \\\\(which includes any device attached to this IS\\\\), you consent to the following conditions:"
    " "
    "- The USG routinely intercepts and monitors communications on this IS for purposes including, but not limited
    to, penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct \\\\(PM\\\\), law
    enforcement \\\\(LE\\\\), and counterintelligence \\\\(CI\\\\) investigations."
    "- At any time, the USG may inspect and seize data stored on this IS."
    "- Communications using, or data stored on, this IS are not private, are subject to routine monitoring,
    interception, and search, and may be disclosed or used for any USG-authorized purpose."
    "- This IS includes security measures \\\\(e.g., authentication and access controls\\\\) to protect USG interests--not for your 
    personal benefit or privacy."
    "- Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching 
    or monitoring of the content of privileged communications, or work product, related to personal representation
    or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work product
    are private and confidential."
    " "
    "See User Agreement for details."
    )

$banner_prep = ForEach ($line in $banner_array){
    "echo -e $line >> /root/banner;"
    }

$V243117 = "/opt/vmware/bin/sso-config.sh -set_logon_banner /root/banner -enable_checkbox Y -title 'DoD User Agreement'"

#Apply changes to the system
cmd /c echo y | & 'C:\Program Files\ExtraPuTTY\Bin\PLINK.EXE' -v -batch -ssh $global:DefaultVIServer.Name -l root -pw $plinkpw $Mode $echonl $V243073 $V243075 $V243093 "rm /root/banner;" $banner_prep $v243117```

答案是:

$V243117 = "/opt/vmware/bin/sso-config.sh -set_logon_banner /root/banner -enable_checkbox Y -title '\''DoD User Agreement'\''"

我忽略了單引號被剝離的原因。

如果您是 gov/edu/law 用戶,您可以免費試用此橫幅。 https://www.cyberintelsystems.com/classification-banner

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM