Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Double Quotation Marks in Write-Host Output

Tags:

powershell

I need to get some double quotations around the GUID=$ntds output. I have tried encompassing the entire string in double quotes to no avail. Single quotes won't work because of the variable.

$Site=Read-Host "ENTER SITE NAME"
$Server=Read-Host "ENTER SERVER NAME"


$NTDS=Get-ADObject -Identity "CN=NTDS Settings,CN=$server,CN=Servers,CN=$site,CN=Sites,CN=Configuration,$((Get-ADDomain).DistinguishedName)" |foreach {$_.objectguid} 
write-host "Repadmin /showobjmeta" * "<GUID=$ntds>"
like image 553
200mg Avatar asked Jan 19 '16 18:01

200mg


1 Answers

You can use another pair of double quotes to escape like

Write-Host "hello ""200mg"""

Which will output hello "200mg"

Your case it would be

write-host "Repadmin /showobjmeta""<GUID=$ntds>"""
like image 132
Rahul Avatar answered Oct 30 '22 20:10

Rahul