问题描述:

I have a very peculiar error when attempting to import some csv data.

This data has links to files contained in a sharepoint site that need to stay the same. (I'm actually writing a script to delete these files).

My problem is these links in particular have dashes in them which either powershell seems to not recognize or the import-csv command cannot handle.

I also want to point out that there are two types of dashes. The hyphen is directly on your keyboard, these are the longer hyphens called "dashes" that are not directly on the keyboard.

If you're not sure what I mean, open up MS Word and FULLY type out the following:

This - is a test.

You will notice that MS Word will auto convert the hyphen to a dash when you strike the space bar before typing the "a" and it will be longer.

Please let me know how I can get powershell to recognize dashes!

Examples:

$web.getListItem("link contains -")

#finds file

#Please note below the actual text is: link contains -

$files = import-csv $path #csv is ms-dos csv

$files[0].Url

#Prints: link contains <box>

$files = import-csv $path #csv is excel general csv

$files[0].Url

#Prints: link contains ?

Solved

Figured this out.

I used the following site to figure out the hex equivalent of my character and did a substitute in excel.

http://www.asciitohex.com/ Turned out the hex equivalent was:

e2 80 93

or Url encode:

%E2%80%93

网友答案:

Solved

Figured this out. I used the following site to figure out the hex equivalent of my character and did a substitute in excel. http://www.asciitohex.com/ Turned out the hex equivalent was:

e2 80 93

or Url encode:

%E2%80%93
相关阅读:
Top