# Powershell cannot find path, adding spaces in string

**URL:** <https://forums.powershell.org/t/powershell-cannot-find-path-adding-spaces-in-string/14671>\
**Category:** PowerShell Help\
**Created:** [July 15, 2020, 11:01am UTC](https://forums.powershell.org/t/powershell-cannot-find-path-adding-spaces-in-string/14671 "2020-07-15T11:01:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![siten0308](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@siten0308](https://forums.powershell.org/u/siten0308)\
**Post date:** [July 15, 2020, 11:01am UTC](https://forums.powershell.org/t/powershell-cannot-find-path-adding-spaces-in-string/14671/1 "2020-07-15T11:01:28Z")

</div>

Hello,

I am working on a Powershell script, it is a simple foreach loop through objects, and the output should be like:

this is coming from a Invoke-SQLQuery into Multiple column row Array  
ForEach ($DB in $DBList)  
{

$DB.Name, Path

}

the output is correct:

Z:\Server1\Database\_001\backup\_001.full

&nbsp;

so when i run it on PowerShell ISE and add in to use that path, the path for some reason adds spaces in between the path:

Z:\Server1\Data base\_001\backup \_001.full

exactly like above happens… not sure why, is this something that happens all the time with powershell?

---

<div class="post-metadata">

**Author:** ![aaron-hardy](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aaron-hardy](https://forums.powershell.org/u/aaron-hardy)\
**Post date:** [July 18, 2020, 8:32pm UTC](https://forums.powershell.org/t/powershell-cannot-find-path-adding-spaces-in-string/14671/2 "2020-07-18T20:32:37Z")

</div>

It’s best to run/test scripts in a PowerShell console as ISE does have some limitations/quirks and may offer slightly different behavior like what you’re seeing. ISE is nice for a number of things but not for complete reliability.

If you get different results between a PowerShell console and ISE, go with the PowerShell console. If you want an experience similar to ISE with more reliability, I have found VS Code to match the PowerShell console consistently.

---

<div class="post-metadata">

**Author:** ![siten0308](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@siten0308](https://forums.powershell.org/u/siten0308)\
**Post date:** [July 19, 2020, 5:31am UTC](https://forums.powershell.org/t/powershell-cannot-find-path-adding-spaces-in-string/14671/3 "2020-07-19T05:31:36Z")

</div>

gotya thank you, actually i now used the Powershell console. also I put a .ToString() at the end, and for some reason that fixed it. thanks again for your assistance 🙂

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:29pm UTC](https://forums.powershell.org/t/powershell-cannot-find-path-adding-spaces-in-string/14671/4 "2024-05-16T20:29:12Z")

</div>


