Powershell – Methods of acquiring admin privileges when working with scripts

Here are a few ways to acquire (prompt for) admin privileges when using PowerShell.

1. In-Script (best way IMO, if it ALWAYS needs to run as admin):

NOTE: If execution policy changes are needed, replace the arguments with the following (if erroring out and closing, add “-noexit”):

Sauce

3. Within PowerShell (or another script):

Start-Process "$psHome\powershell.exe" -verb runas -ArgumentList "-file C:\scripts\script.ps1"

…also run any application as admin with this…
Start-Process cmd -verb runas
Start-Process notepad.exe -verb runas

3. With a .lnk file:

  1. Right Click your PowerShell script file and choose Create shortcut
  2. Name it as you like…
  3. Right-click the shortcut and click Properties
  4. Add powershell.exe -file at the beginning of the Target field
  5. Go to the Shortcut tab
  6. Click Advanced
  7. Check the Run as Administrator box
  8. Click OK
  9. Profit.

Fix for “%ADJ-5-RESOLVE_REQ_FAIL: Adj resolve request failed for (IP)”

Some high-security devices that don’t respond to ping triggered the following:

%ADJ-5-RESOLVE_REQ_FAIL: Adj resolve request failed for 192.168.1.1 on GigabitEthernet1/0/1

Cisco advised me that these are not an issue, and can be safely disabled with:

no ip cef optimize neighbor resolution

This apparently used to be disabled by default, but has since been enabled.
Sauce