The error is not ambiguous, use full paths as ".\" means different things at 
different times…
Or resolve paths with the location of your script, there are cmdlets and 
variables to help here.

From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of Sean Martin
Sent: Friday, June 16, 2017 1:54 PM
To: ntsysadm@lists.myitforum.com
Subject: Re: [NTSysADM] Set-ImageSize Help

Commenting the line that loads system.windows.forms didn't make a difference.

My script, along with set-image.ps1 are in the same directory. I use 
"import-module .\set-imagesize.ps1 within a try/catch block and that succeeds. 
The script fails at the point where it runs:

set-imagesize $sourcephoto -destination $destination -Widthpx $Width -HeightPx 
$height

The variables are set as follows:

$sourcephoto = <uncpath to file>
$destination = <uncpath to directory>
$width = "96"
$height = "96"

I was able to test interactively by setting the same variables and running the 
command. Kind of stumped as to why it won't run within my script.

On Fri, Jun 16, 2017 at 11:10 AM, Michael B. Smith 
<mich...@smithcons.com<mailto:mich...@smithcons.com>> wrote:
One of the problems is that the script loads system.windows.forms – which is 
inherently interactive. However, the script doesn’t appear to use it. So… take 
that line out.

Tell me more about your setup for “running your script”?



From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com>] 
On Behalf Of Sean Martin
Sent: Friday, June 16, 2017 2:35 PM
To: ntsysadm@lists.myitforum.com<mailto:ntsysadm@lists.myitforum.com>
Subject: [NTSysADM] Set-ImageSize Help

Good morning/afternoon,

Looking for a bit of assistance. I'm writing a script to import photos into 
Active Directory and part of the process requires that the photos be resized, 
so I downloaded this gem: 
https://gallery.technet.microsoft.com/scriptcenter/Resize-Image-File-f6dd4a56

Importing and using the set-imagesize cmdlet works just fine when I run through 
the process interactively. However, I get the error "The term 'Set-ImageSize' 
is not recognized as the name of a cmdlet, function......" when I run my script.

I've verified the "module" imports successfully, so I've been banging my head 
on why the cmdlet isn't recognized.

Anyone run into a similar scenario?

Reply via email to