Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 28
  • Last Modified:

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

0
Mike Dias
Asked:
Mike Dias
1 Solution
 
Bill PrewCommented:
You can place double quotes in a text string by escaping them with a backslash.  Is this what you are looking for perhaps?

<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


ยปbp
0
 
Mike DiasAuthor Commented:
Perfect. Thanks.
0

Join & Write a Comment

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now