Query adding Spaces after it is compiled

Support for all customers who have purchased a SAPIEN PowerShell Studio product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
iampedro
Posts: 5
Joined: Wed Dec 18, 2013 12:40 pm

Query adding Spaces after it is compiled

Post by iampedro » Wed Aug 29, 2018 8:49 am

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: 5.5.154
32 or 64 bit version of product: 64
Operating system:
32 or 64 bit OS: 64

#search directory and store uin.mdb into variable
$test = (get-childitem "C:\ROWriterData" -Recurse -include ?????.mdb -Exclude "Ishop.mdb") | select name
$test2string = $test | Out-String
$testtrim = $test2string.Trim()
$testrefine = $testtrim.Remove(0, 286)

#create registry entries
New-Item -Path HKCU:\Software -Name "Progressive Automotive Systems" –Force
New-Item -Path "HKCU:\Software\Progressive Automotive Systems" -Name "R.O. Writer" –Force
New-ItemProperty -Path "HKCU:\SOFTWARE\Progressive Automotive Systems\R.O. Writer" -Name "DataPath" -Value "C:\ROWriterData" -Force

When I compile this with setting in the attached screen shot it add's spaces instead of removing them.

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
Attachments
Ashampoo_Snap_Wednesday, August 29, 2018_10h47m43s_002_.jpg
Ashampoo_Snap_Wednesday, August 29, 2018_10h47m43s_002_.jpg (78.94 KiB) Viewed 1000 times

User avatar
brittneyr
Site Admin
Posts: 64
Joined: Thu Jun 01, 2017 7:20 am

Re: Query adding Spaces after it is compiled

Post by brittneyr » Thu Aug 30, 2018 8:39 am

Trim only removes the leading and trailing spaces of a string. If you want all spaces removed, use the following line:
$test2string = $test2string.Replace( ' ', '')
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
Alexander Riedel
Posts: 6951
Joined: Tue May 29, 2007 4:43 pm

Re: Query adding Spaces after it is compiled

Post by Alexander Riedel » Fri Aug 31, 2018 12:25 am

From your post it is not really clear where you see spaces added.
Packaging does not modify your code, so I am not sure how spaces would be added.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
iampedro
Posts: 5
Joined: Wed Dec 18, 2013 12:40 pm

Re: Query adding Spaces after it is compiled

Post by iampedro » Fri Aug 31, 2018 6:38 am

When I compile it as a EXE and then run it, then it puts extra spaces inside of the Registry creation. Any suggestion to why this occurs?

User avatar
Alexander Riedel
Posts: 6951
Joined: Tue May 29, 2007 4:43 pm

Re: Query adding Spaces after it is compiled

Post by Alexander Riedel » Fri Aug 31, 2018 1:11 pm

You will have to be a little bit more specific. Extra spaces where precisely?
Alexander Riedel
SAPIEN Technologies, Inc.