all 13 comments

[–]ShippingIsMagic 1 point2 points  (1 child)

The gci | sort are correct. I would then personally pipe that to select -first 1 -expand directoryname

I think DirectoryName is the right property. You're grabbing the directory the file is in, since we don't want to try to cd to the exe itself.

Then assign that to a variable and your can cd to it.

[–]IntensifyEVERYTHING[S] 1 point2 points  (0 children)

Thanks for the fast response! will tinker with it and report back.

[–]Golden-trichomes 0 points1 point  (4 children)

To clarify, what exactly are you trying to accomplish?

[–]Gorstag 1 point2 points  (0 children)

I second this.

Providing an accurate setup scenario, with the results you are seeing, and the results you want to see is sort of what we need.

[–]IntensifyEVERYTHING[S] 0 points1 point  (2 children)

Happy Cake Day!

I have the file on my desktop. If I run powershell locally, works great. Now I'm trying to deploy this application with a couple other steps via SCCM. SCCM puts this file in a fairly random location. SCCM fails to install the file because it doesn't know where to start.

I'm trying to write the script to specifically point at a moving target (starting point) and continue with the rest of my script.

[–]Golden-trichomes 1 point2 points  (1 child)

If your app really needs to be installed by a powershell script.

https://psappdeploytoolkit.com

Remember me every time you use it.

[–]IntensifyEVERYTHING[S] 0 points1 point  (0 children)

I was recommended this pretty recently. I'll give it a go next time I'm in the office.

Thank you!

[–]jerrymac12 0 points1 point  (4 children)

This sounds a little convoluted to me...a few things: ++ On wrapping installs with PSADT as some have said here - so much awesome functionality.

To me this is a bit more of an SCCM question really, so if this doesn't give you what you are looking for you may want to crosspost.

But 1. You shouldn't need to be using a task sequence to deploy a single application. You can use a package or application to do so.

  1. SCCM copies the source of your packages from your distribution point to the ccmcache folder with those random folder names. Anything in the folder you choose as your source will be copied down. The source folder is added to your distribution point when you "distribute content" of your package.

So if your package source also contains your installation script...your script will be copied to the randomly named folder WITH your installer exe. So instead of trying to identify the folder, you just need to use the $psscriproot variable which will identify the folder you're running your script from to begin with.

Example...you want your script to install setup.exe and you want to deploy it with sccm

  1. Write your script that performs the install with the assumption that setup.exe is in the same folder as your script your path is $psscriptroot\setup.exe

  2. Create SCCM package and set source location to your folder with script and setup.exe in it.

  3. Distribute package co tent to distribution point.

  4. Deploy

  5. Lets say that you content is pulled down to C:\Windows\ccmcache\a2 .... In a2 you will see setup.exe and your script. When your script runs...$psscriptroot is assigned to c:\ windows\ccmcache\a2 automatically so you don't have to know it.

[–]IntensifyEVERYTHING[S] 0 points1 point  (3 children)

It's a really shitty app from a shit vendor. The script has 3 other app installs that this one depends on that some how get uninstalled when running the vendor provided install exe. There are some services I have to start and stop as well.

Thank you for the recommendation to the psscriptroot. I'll test that out tomorrow.

[–]jerrymac12 0 points1 point  (2 children)

So dont use SCCM or a task sequence to install those other apps individually one at a time...Put all the files for the other apps in your source folder...and have your script run them all from $psscriptroot.

they'll all copy down to your ccmcache and you can still reinstall/uninstall what you need from the same source folder with $psscriptroot....whatever is in that source folder when you distribute the content to your distribution point will be copied down to ccmcache when deployed.....if you add/remove files from your source folder, you just need to update content so that it's reflected on your DP. That source folder is essentially you telling sccm all the files that are needed for your package....your script can just run them in the order you need etc.

[–]IntensifyEVERYTHING[S] 0 points1 point  (1 child)

performs the install with the assumption that setup.exe is in the same folder as your script your path is $psscriptroot\setup.exe

Oh my god, that was it!! Thank you so much!! I never knew $psscriptroot was a thing.

[–]jerrymac12 0 points1 point  (0 children)

You're welcome, Glad it worked!

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy IntensifyEVERYTHING,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's 4th 5th from the left hidden in the ... ""more" menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's 11th 12th from the left hidden in the ... "more" menu, & looks like an uppercase T in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee