Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
- {
- # Relaunch as an elevated process:
- Start-Process powershell.exe "-File",('"{0}"' -f (($MyInvocation.PSCommandPath)+$PSCommandPath)) -Verb RunAs
- exit
- }
- #Start Excel
- $Excel=New-Object -ComObject Excel.Application
- #Open File
- $FilePath='C:\Path\To\OneDrive - Company Ltd\Desktop\testing.xlsx'
- $WorkBook=$Excel.Workbooks.Open($FilePath)
- #Make it visible (Just to check what is happening)
- $Excel.Visible=$true
Advertisement
Add Comment
Please, Sign In to add comment