Formatting got killed.

#If the Excel.exe process is still running for the user's sessionID, kill it

$SessionID = (Get-Process -PID $PID).SessionId

(Get-Process 'Excel' -ea 0 | ?{$_.sessionid -eq $Sessionid}) | stop-process


Thanks


Webster

> -----Original Message-----
> From: listsad...@lists.myitforum.com
> [mailto:listsad...@lists.myitforum.com] On Behalf Of Webster
> Sent: Tuesday, April 07, 2015 8:31 AM
> To: powershell@lists.myitforum.com
> Subject: RE: [powershell] Working with Web Query Files
> 
> To kill the Excel process:
> 
> #If the Excel.exe process is still running for the user's sessionID, kill it
> $SessionID = (Get-Process -PID $PID).SessionId (Get-Process 'Excel' -ea 0 |
> ?{$_.sessionid -eq $Sessionid}) | stop-process
> 
> Thanks
> 
> 
> Webster
> 
> > -----Original Message-----
> > From: listsad...@lists.myitforum.com
> > [mailto:listsad...@lists.myitforum.com] On Behalf Of Webster
> > Sent: Tuesday, April 07, 2015 7:54 AM
> > To: powershell@lists.myitforum.com
> > Subject: RE: [powershell] Working with Web Query Files
> >
> > Answers in-line.
> >
> > Thanks
> >
> >
> > Webster
> >
> > > -----Original Message-----
> > > From: listsad...@lists.myitforum.com
> > > [mailto:listsad...@lists.myitforum.com] On Behalf Of Joshua
> > > Delaughter
> > > Sent: Monday, April 06, 2015 10:53 PM
> > > To: powershell@lists.myitforum.com
> > > Subject: Re: [powershell] Working with Web Query Files
> > >
> > > Could the last line possibly kill other Excel instances that might be
> running?
> >
> > It will kill every instance of Excel running in the user's session.
> >
> > > Does the Quit method in the second to last line not kill the process?
> >
> > Not every time. Which makes me realize that I forgot to implement some
> > code I had tested that looped through and killed all the Excel
> > processes. In my lab, I had 12 Delivery Groups and after processing
> > all 12 groups, I had 12 Excel processes running. I thought I had copied my
> test code into my script.
> > Looks like I forgot to do that.
> > >
> > > Is there a way to get the PID for the particular instance of Excel
> > > that this snippet starts instead?
> >
> > Yep, shown in another reply.
> >
> > >
> > > Sent from my iPhone
> > >
> > > > On Apr 6, 2015, at 5:40 PM, Sean Martin <seanmarti...@gmail.com>
> > > wrote:
> > > >
> > > > Good afternoon,
> > > >
> > > > I've been working on a Powershell script to create/update Mail
> > > > Contacts in
> > > Exchange based on information stored in our SharePoint site. This
> > > may be trivial to some of you, but I thought I would share for those
> > > who are relatively new to Powershell such as myself.
> > > >
> > > > Saving the list from Sharepoint to a Web Query File (.IQY) allows
> > > > for the
> > > presentation of current data each time the file is opened. I had a
> > > hard time figuring out how to work with the file directly, and
> > > didn't have the option of running the script on our Sharepoint
> > > server or remotely against it, so I used the following to save the content
> as a CSV.
> > > >
> > > > # Convert Web Query File to CSV
> > > > $xl = New-Object -C Excel.Application -vb:$false $xl.DisplayAlerts
> > > > = $False $iqy = $xl.Workbooks.Open('<path to IQY file'>)
> > > > $iqy.SaveAs('<Path for saved CSV file>', 6)
> > > > $iqy.Close($false)
> > > > $xl.Quit()
> > > > Get-Process Excel | kill
> > > >
> > > > I can't take credit for the above, but it did take some time track
> > > > it down so I
> > > thought sharing it might help someone else avoid the research time.
> > > >
> > > > - Sean
> >
> >
> >
> > ================================================
> > Did you know you can also post and find answers on PowerShell in the
> > forums?
> > http://www.myitforum.com/forums/default.asp?catApp=1
> 
> 
> 
> ================================================
> Did you know you can also post and find answers on PowerShell in the
> forums?
> http://www.myitforum.com/forums/default.asp?catApp=1



================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

Reply via email to