Categories
Powershell Windows 10 Windows 7

Running batch and powershell scripts as administrator

WINDOWS – RUN BATCH AND PS AS ADMINISTRATORS. This works for Windows 7 and newer. I tested on Windows 7 and 10 64bit and 32bit.

This is a faster vbs version of the below script:
net sess>NUL 2>&1||(echo.CreateObject^(“Shell.Application”^).ShellExecute”%~0″,,,”RunAs”,1 >”%TEMP%\%~nx0.vbs”&WScript “%TEMP%\%~nx0.vbs”&del “%TEMP%\%~nx0.vbs”&exit)

#RUNNING CMD/BAT files as administrator, place this at the top of script after @echo off
net sess>NUL 2>&1||(powershell saps ‘%0’-Verb RunAs&exit)

#RUNNING PS1 FILES as administrator, place this at the top, before all other commands.
# Run this if you need to be running as ADMINISTARTOR
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”))
{
$arguments = “& ‘” + $myinvocation.mycommand.definition + “‘”
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
####################################################

SOURCE: http://www.sevenforums.com/general-discussion/12936-how-run-batch-file-admin-3.html#post3084570

Categories
powershell Programming scripting Windows 10 Windows 7 Windows 8

creating batch file to kick off powershell script in different versions of windows with different commands

I needed the ability to have a powershell script execute specific ways for specific versions of windows, so after some googling, I hodge podged this. Essentially you will run this script first, as a cmd, or batch file:

@echo off
setlocal
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
REM Windows 10 is called be low this
if "%version%" == "10.0" powershell "C:\LocalAdminPolicyUpdate\LocalAdminPolicyUpdate.ps1"
REM Windows 8.1
if "%version%" == "6.3" powershell "C:\LocalAdminPolicyUpdate\LocalAdminPolicyUpdate.ps1"
REM Windows 8
if "%version%" == "6.2" powershell "C:\LocalAdminPolicyUpdate\LocalAdminPolicyUpdate.ps1"
REM Windows Vista
if "%version%" == "6.0" echo Windows Vista.
REM Windows 7
if "%version%" == "6.1" powershell "Set-ExecutionPolicy Unrestricted" && powershell C:\LocalAdminPolicyUpdate\LocalAdminPolicyUpdate.ps1
endlocal

and then this script, labeled LocalAdminPolicyUpdate.ps1 reload the script if it is not running as an admin. This section works for Windows 8+, and does not flag/error on Windows 7, which is why I needed the previous script to kick off ‘what version’ is the OS to run it elevated. I also am running these on PC’s WITHOUT UAC. If you have UAC, the user will get prompted to hit YES on the UAC popup.

The next bit finds all users in the local administrator group, and removes specific users with the $Group.Remove section, and then adds with the $Group.Add. I also added some debugging stuff to see what echo’d out to show me if it exists and it is truely seeing each user.

# Adds local uesr to local administrators account and removing software loaders
# revision 1
# created 2016-04-26

# Run this if you need to be running as ADMINISTARTOR
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
####################################################

$members = net localgroup administrators | where {$_ -AND $_ -notmatch "command completed successfully"} | select -skip 4
#write-output $members

$Computer = $env:COMPUTERNAME
$GroupName = 'Administrators'
$User = $env:USERNAME

$ADSI = [ADSI]("WinNT://$Computer")
$Group = $ADSI.Children.Find($GroupName, 'group')

if ($members -notcontains "E500NT\$env:USERNAME") {
$Group.Add(("WinNT://e500nt/$user"))
}
if ($members -contains "E500NT\Software Loaders") {
$Group.Remove(("WinNT://e500nt/Software Loaders"))
}
if ($members -notcontains "E500NT\ISTechGroup") {
$Group.Add(("WinNT://e500nt/ISTechGroup"))
}
if ($members -notcontains "E500NT\Domain Admins") {
$Group.Add(("WinNT://e500nt/Domain Admins"))
}
#if ($members -contains "E500NT\$env:USERNAME") { echo 1}
#if ($members -contains "E500NT\ISTechGroup") { echo 2}
#if ($members -contains "E500NT\Domain Admins") { echo 3}
#if ($members -notcontains "E500NT\Software Loaders") { echo 4}

Categories
Windows 10

Disabling UAC in Windows 10 but keeping built in apps working like metro apps and edge

If you need to disable UAC, but want to keep the ability to use built in metro apps, like Edge, you can run this:

cmd /c REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System” /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 00000000 /f
cmd /c REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System” /v PromptOnSecureDesktop /t REG_DWORD /d 00000000 /f

If you want some specifics on what other things you can modify to tweak the way UAC handles prompts you can view them here: https://msdn.microsoft.com/en-us/library/cc232762.aspx

There are a few more registry settings you can change, but with these two, in Windows 10, you will at least be able to keep metro apps running. If you want to disable UAC entirely in Windows 10 you can run this:

cmd /c REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System” /v EnableLUA /t REG_DWORD /d 00000000 /f

This will disable UAC, and kill all metro app usage.

Categories
Windows 10

Create batch file to run with elevated permissions to activate windows 10

I had a task of automating Windows 10 upgrades from Windows 7, and one key thing I needed to do was allow for UAC to exist, AND be able to run batch scripts, or powershell scripts as Administrator. Also known as elevated permissions.

I created a bat file with these contents:

set mydir=%~dp0
Powershell -Command “& { Start-Process \”%mydir%2.bat\” -verb RunAs}”

I then created a second bat file with 2.bat, and placed it in the same directory with this:

cscript C:\Windows\System32\slmgr.vbs -ipk xxxx-xxxx-xxxx-xxxx-xxxx
cscript C:\Windows\System32\slmgr.vbs /ato

This only brings up ONE prompt for the user, the UAC prompt to hit yes. No password required, and not VBS pop ups showing status, thanks to cscript.

Categories
APC

Having issues upgrading APC firmware?

I was upgrading my firmware found on apc’s website, it seemed to fail via the sh file you get from the exe downloaded from apc’s website. It was throwing: APC PDU Error: The application was not able to load.

I could still telnet, and look around. I tried rebooting the management interface, it still showed the error. So what I did was do the FTP upload to reflash, and that resolved it. NO need to do a total reset of everything on it, that most seem to recommend.

*Here is the FTP login/upgrade instructions: (Taken from this [kbase article|http://nam-en.apc.com/cgi-bin/nam_en.cfg/php/enduser/std_adp.php?p_faqid=768])*

For AP9617/18/19 cards that have AOS 1.2.0 firmware and below, you will need to first upgrade to AOS 2.0.2 before upgrading to the latest firmware. AOS 2.0.2 should be included as part of the firmware executable located on the firmware download page.

Items are in bold are the commands.

1. To perform an upgrade with this method the Management Card must have been previously configured with a System IP, Subnet Mask, and Default Gateway and attached to the network. In addition, FTP Server must be enabled.

2. Open an MS-DOS command prompt window on a PC which is connected to the network. Change to the directory which contains the firmware upgrade files.
C:\>cd\apc
C:\apc>

3. Open an FTP client session.
C:\apc> ftp 192.168.1.100 (192.168.1.100 being the IP address of the web card)

4. Log in using the Administrator User Name and Password. Your passwords may be different than the defaults, “apc” and “apc”. Typically, the password will appear on the screen as ***.
Connected to 192.168.1.100
220- APC FTP server ready.
220
User (192.168.1.100 :(none)):*apc*
331 User name okay, need password.
Password:*apc*
230 User logged in, proceed.
ftp>

5. Upgrade the aos first. The aos module is the file with the aos prefix.
ftp> bin
200 Command okay.
ftp>
ftp> put aosXXX.bin (XXX being the version number downloaded)
200 Command okay.
150 Opening data connection for aos301.bin
250 Requested file action okay, completed. Management Card
Rebooting….
327680 bytes sent in 5.99 seconds (54.70 Kbytes/sec)
ftp>

6. Close the FTP client session.
ftp>bye
C:\apc>

7. Wait about 20 – 30 seconds.

8. Repeat Steps 3 – 8 again for the application module (sumx for Smart Ups/Matrix, sy for Symmetra, etc). In Step 6, substitute the sumx module file name, in place of the aos module file name. Or the sy prefix for the Symmetra.

Categories
Windows 10

Windows 10 – issues with installed programs not showing up in search

For whatever reason, windows 10 search stopped searching my all apps. I found out re initializing cortona fixes it, which you can do by running an elevated powershell and pasting this into it:

Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}

Once I did that, everything popped up, no reboot was required.

Categories
INTEL NUC

Intel NUC NUC5i5RYH – disable speed step

I am running some homelab stuff with NUC5i5RYH running ESXi. I wanted to know why everything showed up as 1.6ghz and not the 2.7ghz it should burst to. I got a reply from INTEL stating:

The Intel® Core™ i5-5250U Processor is an Ultra-Low power processor (because of the U at the end of the model).

Any U processor cannot disable speedstep which would have allowed me to run full speed, just an FYI to those wanting to do it! You will only get the downclocked speed.

Categories
vmware

Apply ESXi 5.5 Update 2 via cli

With Mike’s excellent post, I was able to update my esxi install from Update 1 to Update 2 via the command line.

Summary:

esxcli network firewall ruleset set -e true -r httpClient
esxcli software profile update -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml -p ESXi-5.5.0-20140902001-standard
esxcli network firewall ruleset set -e false -r httpClient
reboot

To get the list of updates:

esxcli software sources profile list -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml

Categories
Internet Explorer Windows 10 Windows 7 Windows 8

IE9, and IE10 popups to upgrade to IE11 on Windows

We had users complaining about needing to upgrade to IE11, they were running IE8,9, and 10. I tracked down the KB that was installed on patch tuesday to: KB3124275. We have users who have to use Internet Explorer 10 for specific applications, so we cannot ugprade. I removed it from SUS and users PC’s, hopefully this’ll save someone some time.

You can see the MS KB here: https://support.microsoft.com/en-us/kb/3124275

And note part of the way down it says the GR KB is here:

KB3123303 The new “End of Life” upgrade notification for Internet Explorer

Categories
Logitech Software

Logitech Gaming Software and G930 cutting out every 900 seconds

1- Close the LGS (Right click the icon on task bar and select exit)
2- Go to my computer – Windows – Program Files – Logitech Gaming Software – Resources – G930 – Manifest
3- Right click “Device_Manifest” and select edit
4- Look for battery turnOffInterval=”900″ and change the value to “0”
5- Save the file to desktop
6- Copy the file from desktop to My computer – Windows – Program Files – Logitech Gaming Software – Resources – G930 – Manifest
7- Make sure you replace the file
8- Restart the computer
9- The issue should be solved.