Link to home
Start Free TrialLog in
Avatar of Mike Dias
Mike Dias

asked on

Using proper inverted commas, instead of apostrophe?

I have the following example which I'm using for PowerShell. I need to use inverted commas and I'm unsure how to achieve this?

If I leave the following '" + a + "' then it results in 'variable' or in this case, 'username'
If I remove the apostrophe, i.e. " + a + " it results in the variable without the inverted commas
if I double the inverted commas, i.e. "" + a + "" the script fails to run

I need the output of a to present as: "variable" or in this example, "username" not 'username'

What am I missing?

<style>
 body {background-color: white;}
 a {color: yellow; font-size: 14px;font-family: verdana; background-color: navy;}
 define {color: navy; font-size: 13px; font-family: verdana; font-weight: bold;}  
 example1 {color: navy; font-size: 12px; font-family: verdana;}
</style>
<script>
function myFunction() {
    var a = document.getElementById("a").value;


//Get User Properties - Brief	
	pText = "<span style='color: grey;font-size: 75%;font-family: verdana;'>Get-ADUser '" + a + "'</span>";
//Get User Properties - General
	pText = pText + "</br><span style='color: grey;font-size: 75%;font-family: verdana;'>Get-ADUser '" + a + "' -Properties *</span>";
	document.getElementById("Powershell").innerHTML = pText
//Get User Properties - All	
	pText = pText + "</br><span style='color: grey;font-size: 75%;font-family: verdana;'>Get-ADUser '" + a + "' -Properties * | Select *</span>";
	document.getElementById("Powershell").innerHTML = pText
}
</script>
<body>

<font font size="4" face="verdana" color="blue">Powershell: ADUser</font><p>
<p><input type="text" id="a" size="23" maxlength="90" style="font-family: Verdana; font-size: 10; color: #6600FF" value="user.name";"></p>

<button onClick="myFunction()">Generate</button>
<p id="Powershell"></p>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Dias
Mike Dias

ASKER

Perfect. Thanks.