# Powershell script error

**URL:** <https://discourse.chef.io/t/powershell-script-error/10498>\
**Category:** Chef Infra (archive)\
**Created:** [February 28, 2017, 2:52am UTC](https://discourse.chef.io/t/powershell-script-error/10498 "2017-02-28T02:52:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![amb](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@amb](https://discourse.chef.io/u/amb)\
**Post date:** [February 28, 2017, 2:52am UTC](https://discourse.chef.io/t/powershell-script-error/10498/1 "2017-02-28T02:52:02Z")

</div>

Hello All,

When I run powershell\_script resource I’m getting the below error,all my Commands are appended with ‘A’ as shown below  
command:-  
$credential = New-Object System.Management.Automation.PSCredential($username,$securePassword);  
Error:-  
STDERR: The term ‘New-ObjectA’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

---

<div class="post-metadata">

**Author:** ![svucich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/svucich/32/1717_2.png) [@svucich](https://discourse.chef.io/u/svucich)\
**Post date:** [February 28, 2017, 2:57am UTC](https://discourse.chef.io/t/powershell-script-error/10498/2 "2017-02-28T02:57:26Z")

</div>

Just so we are clear, all of these are appended by chef and not within your resource block?

---

<div class="post-metadata">

**Author:** ![amb](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@amb](https://discourse.chef.io/u/amb)\
**Post date:** [February 28, 2017, 3:54am UTC](https://discourse.chef.io/t/powershell-script-error/10498/3 "2017-02-28T03:54:33Z")

</div>

yes it is appended by chef when running, not me

---

<div class="post-metadata">

**Author:** ![spuder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/spuder/32/1382_2.png) [@spuder](https://discourse.chef.io/u/spuder)\
**Post date:** [February 28, 2017, 4:43pm UTC](https://discourse.chef.io/t/powershell-script-error/10498/4 "2017-02-28T16:43:44Z")

</div>

Did you type the command directly into your cookbook, or did you copy and paste?

Copying and pasting from a powershell window inside remote desktop to a workstations is a constant pain since it often introduces hidden characters.

Depending on your text editor, try and configure it to show hidden characters. Or try retyping in the powershell command in your cookbook

---

<div class="post-metadata">

**Author:** ![svucich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/svucich/32/1717_2.png) [@svucich](https://discourse.chef.io/u/svucich)\
**Post date:** [February 28, 2017, 8:16pm UTC](https://discourse.chef.io/t/powershell-script-error/10498/5 "2017-02-28T20:16:19Z")

</div>

Can you please post your Chef server & client versions and also the powershell resource you are trying to run?

---

<div class="post-metadata">

**Author:** ![amb](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@amb](https://discourse.chef.io/u/amb)\
**Post date:** [March 1, 2017, 10:56am UTC](https://discourse.chef.io/t/powershell-script-error/10498/6 "2017-03-01T10:56:32Z")

</div>

chef-client 11.18.12, I’m trying to run start-process

---

<div class="post-metadata">

**Author:** ![amb](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@amb](https://discourse.chef.io/u/amb)\
**Post date:** [March 1, 2017, 11:03am UTC](https://discourse.chef.io/t/powershell-script-error/10498/7 "2017-03-01T11:03:20Z")

</div>

Thanks Spuder,That helped me  
However I’m again getting a different error:This command cannot be run due to the error: Access is denied.  
when running the below code,I guess some permission Issue with system user,please let me know how to run this  
$username=’“username”’  
$password=’“password”’  
$securePassword=ConvertTo-SecureString $password -AsPlainText -Force  
$credential=New-Object System.Management.Automation.PSCredential $username, $securePassword  
Start-Process powershell.exe -Credential $credential -NoNewWindow -ArgumentList “”

---

<div class="post-metadata">

**Author:** ![Chef\_User](https://avatars.discourse-cdn.com/v4/letter/c/b19c9b/32.png) [@Chef\_User](https://discourse.chef.io/u/Chef_User)\
**Post date:** [March 6, 2017, 3:11pm UTC](https://discourse.chef.io/t/powershell-script-error/10498/8 "2017-03-06T15:11:54Z")

</div>

Hi @amb, the user you are using should have domain admin rights over the nodes.

---

<div class="post-metadata">

**Author:** ![amb](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@amb](https://discourse.chef.io/u/amb)\
**Post date:** [March 7, 2017, 9:03am UTC](https://discourse.chef.io/t/powershell-script-error/10498/9 "2017-03-07T09:03:59Z")

</div>

when I run the above code with a local user logging into system I dont get any error, but when I run it as a system user it is prompted.
