How to Delete/Rename files with Path Too Long

The maximum length of a path according to the Windows API, is defined as 260 characters. A subset of Win32 APIs allow you to work around the MAX_PATH restriction by adding the “\?\” prefix. This support up to 32K characters in length but application support is also required (File Explorer do not support it :-))

Windows 10 AU add a “Win32 long Path Support” but not enabled by default and Powershell has finally built-in support for that.
https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/

As workaround you can try to use short filename notation:

cmd /c for %A in ("C:\Documents and Settings\User\NTUSER.DAT") do @echo %~sA

or use subst to map a drive letter to a folder:

subst x: "C:\Very long directory\that exceed\length limit\"

To remove the temporary drive letter:

subst x: /d

How to create Print queue with Powershell

Due to a new printserver rollout I write a powershell script to easily install network printers on the new Windows 2012 R2 printserver.

The script can be found here: https://github.com/lscarso/Powershell/blob/b6eb1a31790774a0433765551c9aeb455cedbd76/New-ProvisioningPrinter/New-ProvisioningPrinter.ps1

If the driver is not on driver store of your printserver, you need to install it before via GUI or using pnputil and Add-PrinterDriver:

pnputil -i -a "C:\Temp\Printers\Ricoh_UniDrv_plc6\x2DSPYP.inf"
Add-PrinterDriver -name "RICOH PCL6 UniversalDriver V4.12"

To create a new Printer Port and the Printer then just run this command:

.\New-ProvisioningPrinter.ps1 -ComputerName MYPRINTSRV -PrinterName PR01 -PrinterAddress 192.168.1.1 -PrinterLocation "Italy, Milano, Reception" -PrinterComment "Asset Number: 01987" -PrinterDriver "RICOH PCL6 UniversalDriver V4.12"

Change ComputerName to your printserver, PrinterName to the name of new print queue you want to create, the PrinterAddress to the IP/HostName of network printer, PrinterDriver to the label of driver to use.

The script create the print queue PR01, shared with the same name and a printer port linked to that printer, named with the IP or HostName you specified on PrinterAddress parameter. SNMP is enabled too on “public” community.

You can also pipe a CSV file with PrinterName, PrinterAddress, PrinterLocation, PrinterComment columns to this script for bulk printers creation:

Import-Csv "C:\Data\Working\printers.csv" -delimiter ";" -Encoding UTF8 | .\New-ProvisioningPrinter.ps1 -ComputerName PRINTSRV

You have now all the printers installed to the new printserver. You need now to configure the default settings:

Set-PrintConfiguration -ComputerName MYPRINTSRV –PrinterName PR01 -PaperSize A4 -Color $False

this configure the PR01 printer with default Paper Size to A4 and to Black & White.

How to Change Skype for Business Spell Check Language

If you enable “Check Spelling as I type” (Options/IM) on Skype for Business (Lync) the spell check language is managed by Windows settings. You can quickly change it from the “Input Method” icon near the clock. On the example, I select english check spelling (with italian keyboard). If you are missing languages, add if from “Control Panel (Settings)/Region & Language”

language_keyboard

How to Specify Office 2016 trusted locations on a per-application basis by using Group Policy

Depending on which application you want to configure, navigate to one of the following locations in the Group Policy Object Editor tree:

User Configuration/Administrative Templates/Microsoft Office Access 2016/Application Settings/Security/Trust Center/Trusted Locations

User Configuration/Administrative Templates/Microsoft Office Excel 2016/Excel Options/Security/Trust Center/Trusted Locations

User Configuration/Administrative Templates/Microsoft Office PowerPoint 2016/PowerPoint Options/Security/Trust Center/Trusted Locations

User Configuration/Administrative Templates/Microsoft Office Visio 2016/Tools|Options/Security/Trust Center

User Configuration/Administrative Templates/Microsoft Office Word 2016/Word Options/Security/Trust Center/Trusted Locations

In the details pane, double-click a trusted location that has not been configured, such as Trusted Location #1, Trusted Location #2, and so on.

In the Trusted Location Properties dialog box, click Enabled and do the following:

In Path, type the path to the folder that you want to trust.
In Date, type today’s date.
In Description, type a description of the trusted location.
Select the Allow subfolders check box if you want all subfolders within the trusted folder to also be trusted

If you specify a network share as a trusted location, you must enable the Allow Trusted Locations on the network setting.

 

How to install Office 2016 on Windows Server 2012R2

After installing Office 2016 on Windows Server 2012R2 with RDS services, trying to lunch one of the Office programs (example Excel), I received this error:

The program cant’ start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer.  Try reinstalling the program to fix this problem.

To solve the problem you need to install KB2999226 update.

But unfortunately on my server, not only this patch was missing but also some required dependencies (Windows Update show me no updates missing!)
One dependency is KB2919355, that have other dependencies…

Here the patches and the steps to solve the issue. The patches order is important:

  1. KB2919442: is a prerequisite for Windows Server 2012 R2 Update and should be installed before attempting to install KB2919355
  2. KB2919355: there are multiple files available for this download and you need to install it on this order:
    1. clearcompressionflag.exe
    2. KB2919355
    3. KB2932046
    4. KB2959977
    5. KB2937592
    6. KB2938439
    7. KB2934018
  3. KB2999226: This is the required update for solve the CRT dll error.

After that Office 2016 application run without error.

 

How to find current Exchange Web Services (EWS) Url

If you need the URL of Exchange Web Services (EWS) on your infrastructures, with outlook running, hold CTRL and right-click on Outlook icon on Notification Bar. Select “Test E-mail Autoconfiguration…”. Click on “Test” button. When the test is finished, on “XML” tab you will find something like this:

<EwsUrl>https://mydomain.local/EWS/Exchange.asmx</EwsUrl>
<EmwsUrl>https://mydomain.local/EWS/Exchange.asmx</EmwsUrl>

How to change Network Location in Windows 10

The easiest option is to use powershell. Open powershell with admin rights.

Get Network Name with this command:

Get-NetConnectionProfile

The result on my case…

Name : Network 4
InterfaceAlias : Ethernet
InterfaceIndex : 3
NetworkCategory : Public
IPv4Connectivity : Internet
IPv6Connectivity : NoTraffic

Check the Name and the NetworkCategory.

Change the NetworkCategory (Location) from Public to Private with:

Set-NetConnectionProfile -Name “Network 4” -NetworkCategory Private