DMT Powershell Help

It might not show on Nancy’s post (does show clearer in the screen shot)

But the inner quotes need t be escaped with a grave

$SourcePath ="`"C:\Users\NHoyt.CHEMPUMP\Desktop\Ready to Attach1\DMTSNAtts.txt`""
1 Like

@Banderson Just curious, what version of Windows and PowerShell are you using?
I ask because I have a client on WS 2008R2 and they were having all kinds of inconsistencies with the code I posted on my blog and it ended up being that their PowerShell was an older version and somethings either did not work at all or some parsing functions did not exist.
In most cases we found workarounds to fit that version.

Just saw this, not tested or anything, just thought it might be applicable some how:

Now this is at the PowerShell prompt but notice how they have to deal with the space by using a backtick right before the space? Maybe that’s all you need to do?

Another example:

Quick security note: encourage PowerShell users to upgrade. Older versions of PowerShell have security issues. Windows PowerShell 2.0 Deprecation - PowerShell Team

1 Like

version: whatever comes with windows 10. I don’t see how to check the version (I’m a newbie to powershell)

I’ll try the backtics when I get a chance. Thanks.

does this mean I’m on version 1? Is that bad? Looks like I will have to get the new version.

image

This did it. I was just having a really hard time keeping a single quote and a backtick straight. Once I got that it worked.

(fyi The backtick in front of the space did not work, on the version I am on anyways)

2 Likes

At the prompt, type:

$PSVersionTable

ok, Mine is the same as yours, so I guess I’m good. :relieved: (off topic, these emojis are crap…)

This is mine… (them’s alotta versions)
image

Hi Nancy,

You may want upgrade that 2.0 version. Here’s a nice security review for PowerShell.

Mark W.

3 Likes

Or upgrade to that latest version of PowerShell… 5.1 … or is 6 out by now?

https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell?view=powershell-6#upgrading-existing-windows-powershell

1 Like

So just ran into this issue myself. I wanted to have a csv that has all my output file names, the SQL statement for extraction, the DMT template name in it as well.

Then passing in all the items in as variable in a foreach loop. But for the life of me I could not get the escaping of the DMT Template name. Just like @Rick_Bird had had difficulty with those blasted spaces!

I ended up wrapping the delimiters around the $items variable instead of trying to add the quotes in the field in the file.

$dmttemplate = "`"$($item.DMTTemplate)`""
Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Add -Update -Import $dmttemplate  -Source $Source"

I was looking for an escape… I just didn’t know it at the time!
Thanks Rick!

1 Like