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

118 Views Asked by At

I am automating the baseline configuration process to include DISA STIGs for ESXi and vCenter servers. The portion I am having an issue with is updating the title for the logon banner, specifically, as soon as the code hits the first white space it dumps the rest of the title. For example, the goal is to display "DoD User Agreement", however, after running the script it only displays "DoD". If I enter "DoD_User_Agreement", it displays the entire string. How do I get it to display a title with white space? If I run the command via a SSH terminal or locally it runs correctly.

Here is a snippet of the code, the V-243117 variable is the line that contains the specific command line:

$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```
1

There are 1 best solutions below

0
On

The answer is:

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

I neglected to account for the single quotes being stripped off.