Run PowerShell Script in Schedule Tasks

The following will allow you to run a Powershell script as a scheduled task. These instructions have been tested on a Windows 7 64bit computer.

Before proceeding, make sure your Powershell script runs without any errors. The best way to make sure your script is running fine is by calling it from a command prompt.

Note: Make sure you run Set-ExecutionPolicy from an elevated Powershell window to make sure your system (Windows 7) is allowed to run Powershell scripts.

  1. Open a Command Prompt window
  2. Run: powershell -file <your ps script file>
  3. Make sure it executes properly

 

Now, open Windows 7 Task Scheduler:

  1. In the Actions tab
  2. Power shell is found at: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    1. You can also just use powershell.exe
  3. In Add arguments (optional) field, add the following: -File “C:\Path-to-your-script\Your-ps-script.ps1”
    1. Sample: -File “C:\Program Files (x86)\Info Folder\Get-Speed.ps1”
  4. In Start in (optional) field, add the following: C:\Program Files (x86)\Info Folder
    1. Sample: C:\Program Files (x86)\Info Folder

2016-09-19_1151

I’m not going to go over the other sections as this is the main section to be able to execute Powershell scripts from Schedule Tasks.

, , ,

Leave a comment

Get Active Network Adapter

Recently I had the need to create a script to find out what was the active network adapter in our server, so after some ideas from the web, I came up with a one line PowerShell script that helped me achieve my goal.

Note: Get-NetAdapter is a PowerShell commandlet that’s present on Windows 8 and Windows Server 2012 R2. This command will not work on Windows 7.

Get-NetAdapter | Where-Object {($_.LinkSpeed -eq “1 Gbps”) -and ($_.Status -eq ‘Up’)}

In this line, I’m basically getting the adapter with status ‘Up’ and with a linkspeed equals to ‘1 Gbps’. One can change LinkSpeed property to match your server’s network adapter speed(s).

Leave a comment

Deploying Oracle JAVA

As of JAVA 8 Update 73, this is the easiest way I’ve found to deploy JAVA on a corporate environment.

  1. Download JAVA from here
    1. You’re going to select the Windows Offline download option
  2. Take a look at the many installation options now available for the JAVA EXEcutable file, those options can be found here
  3. From an elevated command line, you’re going to run the JRE executable file with the options you select from step 2
    1. Here’s just a sample command line (all in one line):
    2. jre-8u73-windows-i586.exe EULA=Disable INSTALL_SILENT=Enable AUTO_UPDATE=Disable REBOOT=Disable REMOVEOUTOFDATEJRES=1
    3. You should be able to find the meaning of each installation option by reading the document in step 2. In essence, I’m installing JAVA and accepting the EULA, a silent install with JAVA auto update disabled as well as removing any outdated installations of JAVA and finally rebooting is disabled.

JAVA Instal

Note: Here’s a great JAVA 8 deployment blog in case you need other means of installing it

 

For those using System Center Configuration Manager 2012 (SCCM 20120), one of the ways to create an application deployment would be to use ‘manual’ deployment type and use a script to install JAVA. In the script I used, I was able to use START /WAIT command to execute the JRE file.

Leave a comment

SCCM 2012 R2 SP1 & PXE-E53 Error(s)

In SCCM 2012, you may encounter the following PXE error message:

PXE-E53: No  boot filename received
PXE-M0F: Exiting Intel Boot Agent
Selected boot device failed. Press any key to reboot….

IMG_1755

Unfortunately, there are many instances that will generate the error message above; one of those instances is when you’ve not set your Windows PE x86 to deploy in your distribution point.

Yes, even if you’re using Windows PE (x64), you must enable the (x86) version. (see below)

9-21-2015 12-03-34 PM

, , , , , , ,

Leave a comment

SCCM 2012 R2 SP1 and User Device Affinity

I’m using the Boot Image to set User Device Affinity (UDA) to devices managed by SCCM 2012 R2 SP1.

First, here’s how we script looks to:

Dim userDA, smsUserMode
Set env = CreateObject("Microsoft.SMS.TSEnvironment")

' We enable UDA variable here - before assigning user
smsUserMode = "Auto"
env("SMSTSAssignUsersMode") = smsUserMode

userDA = Inputbox("Type a valid Active Directory user account." &amp; vbCrLf &amp; vbCrLf &amp; _
"Format: DOMAIN\Username", "Name of primary user for device...")
env("SMSTSUdaUsers") = userDA

' writing to log
wscript.echo "User device affinity set to " &amp; env("SMSTSUdaUsers")
wscript.echo "We're going to set UDA by setting SMSTSAssignUsersMode variable to: " &amp; env("SMSTSAssignUsersMode")

I’m going to save this script on a shared network location. This code is widely used by many people, and I’m not the creator of it; I’ve just slightly modified it.

Next, I’m going to customize the Boot Image file in SCCM, see screenshot.

Boot Image UDA

That’s it!

, , , , , , ,

Leave a comment

Deploy JAVA & Disable JAVA’s AutoUpdate

The following will allow you to deploy JAVA, using an MSI, with the ability to disable JAVA’s AutoUpdate feature.

  1. Download JAVA manually from here
    1. You can download 64 and 32 bit version
  2. Next, run the installation file, but do not click anything else after the first screen
  3. Go to C:\Users\YourUserName\AppData\LocalLow\Oracle and find the extracted MSI file
  4. Copy the MSI to another location and use ORCA to modify the MSI fi le
    1. ORCA can be downloaded from here
  5. Go to the Properties table and change the properties highlighted in the screenshotJAVA No AutoUpdate
  6. Save the MSI and you’re now ready to deploy JAVA

, , , , ,

Leave a comment

Windows 10 Licensing On A Windows Server 2012 R2

Recently I began to get ready for Windows 10, and part of that process was to get our licensing servers up to date. Since I was getting multiple answers on Microsoft TechNet forums, I decided to open a call with Microsoft Support and get a definitive answer – all information below has been confirmed with Microsoft.

First, Windows Server 2008 R2 will be able to provide licenses for your Windows 10 fleet, with a catch. Microsoft will be deploying a Hotfix for Windows Server 2008 R2 in a month or two, maybe a bit longer, so if your organization can wait, then just hold on tight.

 
Note: Windows Server 2008 is not supported for Windows 10 licensing, this was made clear on my call to Microsoft Support!
 
After installing the Volume Activation feature, the following must be done to prepare Windows Server 2012 R2 to licensing Windows 10 clients.
  1. Add a Windows Server 2012 R2 HotFix, which can be found here
    1. Reboot server
  2. Add a SRV record to any of your primary domain controllers
    New SRV Record
  3. Wait for all domains to synchronize DNS information
  4. Install the correct KMS host server key
    1. You’ll need to go to licensing.microsoft.com and download the proper KMS host server key
    2. For Windows 10 licensing on a Windows Server 2012 R2 server, we’ll need the following key: Windows Srv 2012R2 DataCtr/Std KMS for Windows 10
    3. Use the following commands, in an elevated CLI, to register and activate the KMS host server key
      1. SLMGR /ipk CCCCC-XXXXX-PPPPP-KKKKK-MMMMM
      2. SLMGR /ato
  5. After allowing all DCs to synchronize, we’re going to run a command to make sure that the new KMS server is ready to authenticate clients
    a. nslookup -type=srv _vlmcs._tcp
    b. Copy and paste the command in step 5a onto a desktop and results should be as shown in the screenshot belowNslookup for SRV
  6. These steps will allow you to install the proper host server key and allow your Windows 10 clients to get licensed.

, , , , ,

Leave a comment