0

I have powershell script with input parameters, but when I run it, some input is ignored and script just uses same parameters as in previous run.

I assume ps remembers some frequent parameters in cache, is there a way how to force it to always take new parameters?

Called with

-ExecutionPolicy bypass 
-command xxx.ps1
-subject "Report: xxx"
-from "xxx@yyy.com"
-fordate "xxxx-xx-xx"
-path "xxx\"
-fileName "xxx.zip"

Parameter declaration in script

Param(
  $subject,
  $from,
  [DateTime]$fordate,
  $path,
  $fileName
)

Thanks a lot

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Nirgan
  • 3
  • 1
  • 4

1 Answers1

0

The problem was with one parameter that was split with space (for example 'report: xxx'), even though it was separated in commas, powershell only took the part before space (which was same for all cases - thats why i thought it didnt take new parameter).

I have fixed the problem with using -file instead of -command at the start (How to pass in a string with spaces into PowerShell?)

I think I will delete this question later because it is not the problem which was described in title/post (has zero value for future users i guess), but i still want to thank all people that commented or took a minute to think about it

Nirgan
  • 3
  • 1
  • 4