Solved

Problem running a powershell script

Posted on 2013-11-13
10
258 Views
Last Modified: 2013-11-13
I have a very simple powershell script (only 2 lines) as two lines indicated below

cls
$Folder = “C:\Temp1\\Temp2

But I get errors when I run it inside Administrator Power Shell as indicates the line below

c:\Temp1\a,ps1


Can anyone tell me what do I do wrong?  Thanks
Capture.JPG
Capture2.JPG
0
Comment
Question by:tommym121
  • 4
  • 3
  • 3
10 Comments
 
LVL 14

Assisted Solution

by:Ram Balachandran
Ram Balachandran earned 100 total points
ID: 39646935
Interesting,  “C:\Temp1\\Temp2” is just a value set in $Folder.

Are you getting any error when you execute this line directly from powershell window ?
0
 

Author Comment

by:tommym121
ID: 39646939
NO
0
 
LVL 14

Expert Comment

by:Ram Balachandran
ID: 39646999
how you are executing the powershell script  ?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 5

Accepted Solution

by:
Dontmilkthis earned 400 total points
ID: 39647003
It looks like you're using some special characters that are normally used in Word to make things look pretty.

for example those quotation marks aren't true quotation marks.

not sure what the A characters are in the output, but i'd suggest manually typing out the powershell script again in notepad or a normal text editor

"normal quotes"
“quotes copied from your example”

if you look really close, you can see the difference
0
 

Author Comment

by:tommym121
ID: 39647010
Dontmilkthis,

Thanks for your help.  I think when copy the code from the web page, I might have copy some hidden character(s) that cause the problem. When I retype it, i have no problem.
0
 

Author Closing Comment

by:tommym121
ID: 39647012
Thanks for your help
0
 
LVL 5

Expert Comment

by:Dontmilkthis
ID: 39647017
Yeah it's a bit of a pain when copying from a website, Word doco or email that does some replacement of normal expected characters with characters from the extended set simply for cosmetic effect.

things to look out for mostly are quotation marks, apostrophes and hyphens/dashes.
these are the most common ones I've found.

Glad I could help
0
 
LVL 14

Expert Comment

by:Ram Balachandran
ID: 39647021
Best practice is to copy the code from website to a notepad, and from there copy to editor.
0
 
LVL 5

Expert Comment

by:Dontmilkthis
ID: 39647027
I find notepad is still capable of maintaining the extended set characters, at least in windows 7, I don't recall about previous versions.
0
 

Author Comment

by:tommym121
ID: 39647029
ram_kerala

I did copy to the notepad and save it. Now I know I have to pay more attention to the code on internet.  Thanks.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office 365: Content Search, Search and Purge 17 55
Add a line to move accounts to another OU 2 26
Copy Function with attributes 1 23
Powershell script reporting 12 23
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question