How to Delete WSD printer Port

I had a Windows 2012 R2 printserver where a WSD port was still there after printer deletion. Delete only the port was not possible (operation not permit).

The spooler will delete the port only if it is assigned to a printer and you are deleting the printer. As workaround you can create a fake printer using this port and a preinstalled driver, then delete the printer.

But using powershell is possible to work less…

List all the WSD Printer Port:

Get-PrinterPort -Name wsd*

Delete the WSD Printer Port (PortName):

Remove-PrinterPort -Name PortName

or if you have only one WSD port:

Remove-PrinterPort -Name (Get-PrinterPort -Name wsd*).name

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 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

How to Change Remote App Icon on Windows 2012 R2

Changeing icon on RDS Remote App is possible only from Powershell.

Open administrative Powershell, import RemoteDesktop module and check first the current IconIndex and IconPath settings:

Import-Module RemoteDesktop

Get-RDRemoteApp -alias “MyApp” | fl

Then set the IconPath and IconIndex to the desired value. Found IconIndex counting the icons present on EXE,DLL,ICO until you reach the desired one starting from 0:

Get-RDRemoteApp -Alias “MyApp” | Set-RDRemoteApp -IconPath “C:\MyProg\MyProg.ico” -IconIndex 0

It’s possible also to change directly the .ico file you found on C:\Windows\RemotePackages\CPubFarms\CPubRemoteApps on the broker if you already have the icon on .ico format.

How to use Portable Visual Studio Code and GIT

I started to use Visual Studio Code as my primary Editor tool. I used portable version of Visual Studio Code and GIT to avoid installation and be able to quickly use different machines. For this purpose I also prefered to use “Workspace Settings” instead of “User Settings” in Visual Studio Code.

Download and install Visual Studio Code Portable from https://github.com/garethflowers/vscode-portable

Download and install Git Portable from https://github.com/sheabunge/GitPortable

Open Visual Studio Code and create a “Workspace Settings” with path to portable GIT and in my case Proxy Settings:

// Place your settings in this file to overwrite default and user settings.
{
    // The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables
    "http.proxy": "http://192.168.1.1:80",

    // Path to the git executable
    "git.path": "C:\\Data\\GitPortable\\App\\Git\\Bin\\git.exe"
}

If you develop in powershell with this repository make sense to add Powershell Extension (https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell) and configure powershell as integrated terminal:

// 64-bit PowerShell if available, otherwise 32-bit
"terminal.integrated.shell.windows":"C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"

Open Visual Studio Code and initialize a GIT repository

VisualStudioCode_Git_Initialize

Open GIT Portable, go to local repository path and config GIT repository:

git remote add origin https://mygitserver.com/_git/mygitrepository
git config http.proxy "<a href="http://192.168.1.1:80">http://185.46.212.34:80</a>"
git config user.email "myemail@mydomain.com"
git config credential.helper wincred

Check also http://www.theregister.co.uk/2015/12/07/visual_studio_code_git_integration/ to use Visual Studio Team Service as a provider.