Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Call a function in a new PS window and passing parameters to it.

$
0
0

I am trying to call a function that adds an outlook calendar event; however, I have to call the function using different creds.  so, I was trying this:

$daystodeletebackup = 30
$date = (get-date).AddDays($daystodeletebackup) 
$newdate = $date.ToString('MM/dd/yyyy HH:mm')
$newdate
$DatabaseName = "Database"
$SQLInstanceName = "Server"

$creds = Get-Credential

Start-Process powershell.exe -Credential $creds Add-CalendarMeeting -subject "DELETE BACKUP FILE" -Body "DELETE Backup File from DECOMMISSIONED database $DatabaseName on Server $SQLInstanceName" -Location $SQLInstanceName -MeetingStart $newdate -Reminder 30

But I get an error: System.Management.Automation.ParameterBindingException: A parameter cannot be found that matches parameter name 'subject'

If I run it and comment out everything past Add-CalendarMeeting it will work but I have to enter in the parameters.  Is there anyway for me to pass the parameters into the new PS window?



Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>