Install InfoPath 2013 Silently

email me

If you’re not aware, Microsoft has removed InfoPath from Office 2016. So, the last version of InfoPath is from Office 2013. Microsoft has packaged these as standalone packages to make things a little easier, but now the trick is to get it silently installed on your fleet of computers. Here are the steps I’ve come up with to silently install InfoPath 2013.

Step 1 – Download InfoPath standalone packages from here

Step 2 –  Extract files from EXE(s):
infopath_4753-1001_x64_en-us.exe /extract

Step 3 – Open “infopathr.ww” folder

Step 4 – Open Config.xml in notepad

Step 5 – Modify the Config.xml file like this:

<Configuration Product=”Infopathr”>
<Display Level=”none” CompletionNotice=”no” SuppressModal=”yes” AcceptEula=”Yes” />
</Configuration>

Step 6 – Add the following to a script of your choice

PathToFile\setup.exe /config PathToFile\infopathr.ww\config.xml

* if you have problems activating, try this:

cscript “C:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs” /sethst:YourKMSServerIP
cscript “C:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs” /act

 

Notes

  • InfoPath 2013 is now available in the Microsoft Download Center.
  • InfoPath 2013 is the last version Microsoft will release, and support will be extended until 2026.
  • Microsoft has not currently announced plans for InfoPath replacement
    • FoSL was discontinued
    • PowerApps is a vehicle for consuming Azure App Services
    • Microsoft Forms are for teachers to give quizzes mostly
  • SharePoint 2016 will support InfoPath browser forms (contrary to earlier statements).
  • Office 365 will support InfoPath browser forms ‘until further notice’ officially, with indications that may mean until one year after the release of Office 2016.
  • InfoPath browser forms do not work on mobile devices when SharePoint Online mobile view is enabled.

Adding PowerShell support to Windows PE

email me

Step 1 – Download the WAIK Tools

Step 2 – Create folder structure C:\WinPE\mount

Step 3 – Move a copy of your boot.wim into C:\WinPE

Step 4 – Open admin command prompt

Step 5 – copype amd64 C:\WinPE

Step 6 – Run the following commands in the console

Dism /Mount-Image /ImageFile:”C:\WinPE\boot.wim” /Index:1 /MountDir:”C:\WinPE\mount”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFX_en-us.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab”

Dism /Add-Package /Image:”C:\WinPE\mount” /PackagePath:”C:\Program Files\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab”

Dism /Unmount-Image /MountDir:C:\WinPE\mount /Commit

List BIOS Settings using PowerShell

email me

Something really nice is to have the ability to modify BIOS settings directly. Well, out of necessity, I needed to temporarily disable the USB Boot device; the HP EliteBook G3 autoboots to an external USB HD, causing all kind of flow process issues with imaging computers. So, I figured out how to first list those BIOS settings (with their corresponding values), and then how to change them.

Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class hp_biosEnumeration |
Format-Table Name,Value -AutoSize

 
Output (click for zoom)

Add Entries into SQL Database

email me

Eventually, you’re going to want to send information from clients (create records) to a database. There are many ways to do this, but using PowerShell is the most modern way.

This script accesses the ‘Test’ DB, and creates a record with the client computer name and timestamp.

[String]$dbname = "Test";

$computername = $env:COMPUTERNAME
$timeformat='MM-dd-yyyy hh:mm:ss tt'
$time = (Get-Date).ToString($timeformat)

# Open Connection with Windows authentication to local SQLSERVER.
$con = New-Object Data.SqlClient.SqlConnection;
$con.ConnectionString = "Data Source=.;Initial Catalog=Test;Integrated Security=True;";
$con.Open();

# Create the record.
$sql = "INSERT INTO Inventory.ComputerInfo ([ComputerName],[AcquiredDate])
VALUES('{0}','{1}')" -f
$computername,$time
$cmd = New-Object Data.SqlClient.SqlCommand $sql, $con;
$cmd.ExecuteNonQuery();

# Write-Host "Computer Name: $computername";
# Write-Host "Time: $time";
# Write-Host "SQL Command: $sql";
Write-Host "Record has been created";

# Close and Clear all objects.
$cmd.Dispose();
$con.Close();
$con.Dispose();

Create SQL Database using PowerShell

email me

Using this PowerShell code, you can either run it directly in the console, or make a CreateDB.ps1 file, to add a new SQL DB. Note, you could use with some of the previous PS code to create a single solution to automate the creation of the database, add the schema, and add tables.


[String]$dbname = "MyNewDatabase";

# Open ADO.NET Connection with Windows authentification to local SQLSERVER.
$con = New-Object Data.SqlClient.SqlConnection;
$con.ConnectionString = "Data Source=.;Initial Catalog=master;Integrated Security=True;";
$con.Open();

# Select-Statement for AD group logins
$sql = "SELECT name
        FROM sys.databases
        WHERE name = '$dbname';";

# New command and reader.
$cmd = New-Object Data.SqlClient.SqlCommand $sql, $con;
$rd = $cmd.ExecuteReader();
if ($rd.Read())
{	
	Write-Host "Database $dbname already exists";
	Return;
}

$rd.Close();
$rd.Dispose();

# Create the database.
$sql = "CREATE DATABASE [$dbname];"
$cmd = New-Object Data.SqlClient.SqlCommand $sql, $con;
$cmd.ExecuteNonQuery();		
Write-Host "Database $dbname is created!";


# Close & Clear all objects.
$cmd.Dispose();
$con.Close();
$con.Dispose();

Add Schema, Add Table into a SQL Test Database

email me

This is how you would create a schema and add a table into your own Test database.


Add-Type -Path 'C:\Program Files\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.SqlServer.Smo.dll'

$ns = 'Microsoft.SqlServer.Management.Smo'
$svr = new-object ("$ns.Server") $inst

#Create reusable datatype objects
$dtint = [Microsoft.SqlServer.Management.Smo.Datatype]::Int
$dtvchar100 = [Microsoft.SqlServer.Management.Smo.Datatype]::NVarChar(100)
$dtdatetm = [Microsoft.SqlServer.Management.Smo.Datatype]::DateTime

#Reference the database.
$db = $svr.Databases["Test"]

#Schema variables
$SchemaName = "Inventory"
$Schema = $db.Schemas[$SchemaName]

#Ensure that the schema, if not, create it
if (!($Schema)) 
{
    Write-Host "Creating Schema: $SchemaName"
    $Schema = New-Object ('Microsoft.SqlServer.Management.SMO.Schema') ($db, $SchemaName)
    $Schema.Create()
}

#Create the table in the HumanResources schema
$tbcomp = new-object ("$ns.Table") ($db, "ComputerInfo", "Inventory")

#Create the ComputerID column
$colcoid = new-object ("$ns.Column") ($tbcomp, "ComputerID", $dtint)
$colcoid.Identity = $true
$colcoid.IdentitySeed = cls
$colcoid.IdentityIncrement = 1
$tbcomp.Columns.Add($colcoid)

#Create the ComputerName column
$colconame = new-object ("$ns.Column") ($tbcomp, "ComputerName", $dtvchar100)
$colconame.Nullable = $false
$tbcomp.Columns.Add($colconame)

#Create the AcquiredDate column
$colacqdate = new-object ("$ns.Column") ($tbcomp, "AcquiredDate", $dtdatetm)
$colacqdate.Nullable = $false
$tbcomp.Columns.Add($colacqdate)

#Create the Primary Key
$idxpkcomputer = new-object ("$ns.Index") ($tbcomp, "PK_AcquiredComputer")
$idxpkcomputer.IndexKeyType = "DriPrimaryKey"
$idxpkcomputer.IsClustered = $true
$idxpkcomputercol = new-object ("$ns.IndexedColumn") ($idxpkcomputer, "ComputerID")
$idxpkcomputer.IndexedColumns.Add($idxpkcomputercol)
$tbcomp.Indexes.Add($idxpkcomputer)
 
#Create the table
$tbcomp.Create()

Add New Table into AdventureWorks2016 Database

email me

This is how you would add a new table into a SQL database using PowerShell.

The idea is, if HR was to assign an employee a laptop, and then upon first login, the user info would be recorded into the database. You could extend this to record IP address, computer serial number, MAC addresses, etc.

Add-Type -Path 'C:\Program Files\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.SqlServer.Smo.dll'

$ns = 'Microsoft.SqlServer.Management.Smo'
$svr = new-object ("$ns.Server") $inst

#Create reusable datatype objects
$dtint = [Microsoft.SqlServer.Management.Smo.Datatype]::Int
$dtvchar100 = [Microsoft.SqlServer.Management.Smo.Datatype]::NVarChar(100)
$dtdatetm = [Microsoft.SqlServer.Management.Smo.Datatype]::DateTime

#Reference the AdventureWorks database.
$db = $svr.Databases["AdventureWorks2016"]

#Create the table in the HumanResources schema
$tbcomp = new-object ("$ns.Table") ($db, "ComputerInfo", "HumanResources")

#Create the ComputerID column
$colcoid = new-object ("$ns.Column") ($tbcomp, "ComputerID", $dtint)
$colcoid.Identity = $true
$colcoid.IdentitySeed = cls
$colcoid.IdentityIncrement = 1
$tbcomp.Columns.Add($colcoid)

#Create the ComputerName column
$colconame = new-object ("$ns.Column") ($tbcomp, "ComputerName", $dtvchar100)
$colconame.Nullable = $false
$tbcomp.Columns.Add($colconame)

#Create the AcquiredDate column
$colacqdate = new-object ("$ns.Column") ($tbcomp, "AcquiredDate", $dtdatetm)
$colacqdate.Nullable = $false
$tbcomp.Columns.Add($colacqdate)

#Create the Primary Key
$idxpkcomputer = new-object ("$ns.Index") ($tbcomp, "PK_AcquiredComputer")
$idxpkcomputer.IndexKeyType = "DriPrimaryKey"
$idxpkcomputer.IsClustered = $true
$idxpkcomputercol = new-object ("$ns.IndexedColumn") ($idxpkcomputer, "ComputerID")
$idxpkcomputer.IndexedColumns.Add($idxpkcomputercol)
$tbcomp.Indexes.Add($idxpkcomputer)

#Create the table
$tbcomp.Create()

Windows 10 TPM and BitLocker

email me

It seems like with each release of Windows, Microsoft comes out with new and fun ways to stress out developers and sys admins. In Windows 10, many of the BitLocker commands that worked in Windows 7 no longer work (most of the PS cmdlets became available in Windows 8.1).

Classic Microsoft

Now, to come up with a complete enterprise solution (without purchasing MBAM-like products), you’ll have to string together a few different technologies and PowerShell commands.

So far, this is what I’ve come up with, which works to enable the TPM and start BitLocker. I have added popups, splash screens, and more complex code…but, have left that out this post, just for the sake of simplicity.
         

Two things you may have to do

(1) Enable TPM using Microsoft’s BitLocker Deployment Script.  Use this with the /on:tpm option.

(2) And, if you have newer HP computers, you’ll need to set the BIOS password before enabling the TPM. You can use the HP BIOS Configuration Utility to do this. I had no issues creating the encrypted password and setting the BIOS password.

 

What the commands and process look like

“C:\SetPW.exe” /npwdfile:”C:\password.bin”

“C:\enablebitlocker.vbs” /on:tpm /l:c:\bitlocker.log

{a reboot will be required}

{the BIOS PW was set – Press F1 to enable TPM}

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command “Initialize-Tpm -AllowClear -AllowPhysicalPresence”

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command “Initialize-Tpm

C:\windows\system32\manage-bde -protectors -add C: -tpm

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command “Enable-BitLocker -MountPoint “C:” -EncryptionMethod Aes256 -UsedSpaceOnly -RecoveryPasswordProtector”

C:\windows\system32\manage-bde.exe -protectors -adbackup c: -id {9557D616-0BD0-4B2A-8A2A-9DD4C5C21CCC}

{reboot to start encrypting}

 

Reference

https://blogs.technet.microsoft.com/heyscriptingguy/2015/05/25/powershell-and-bitlocker-part-1/

https://technet.microsoft.com/en-us/library/jj649829(v=wps.630).aspx

 

Notes

The get-tpm cmdlet in PowerShell – what a correctly setup TPM looks like

 

A drive that has been successfully encrypted using Bitlocker