RSS

Tag Archives: CMD

PowerShell – PowerShell generated batch file results in error þ is not recognized as an internal or external command

PowerShell – PowerShell generated batch file results in error þ is not recognized as an internal or external command

Some time ago, a colleague told me he was having trouble generating a batch file using PowerShell. The batch file as generated, but when he tried to run the batch file, it resulted in an error containing:
þ is not recognized as an internal or external command

In the batch file, the character þ was nowhere to be found.

The code he used to generate the batch file was as follows:

$Batscript = ‘D:\batscript.cmd’

IF(Test-Path -path $Batscript)

{

Remove-Item $Batscript

}

$SSIDImport = Get-Content ‘D:\SSID.txt’

Foreach($SSID in $SSIDImport)

{

“nsrmm.exe -d -S $SSID -y $SSID | Out-File -filepath $Batscript -Force -Append

}

‘nsrim.exe -X’ | Out-File -FilePath $Batscript –Append

After Googling a bit I stumbled across a similar issue: http://powershell.org/wp/forums/topic/strange-character-error-when-running-native-cmdline-app/

Thanks to Dave Wyatt I learned that the default encoding for Out-Filepath is Unicode which many command line tools cannot handle. With this knowledge, the solution was to simply specify the encoding for Out-File as shown below.

$Batscript = ‘D:\batscript.cmd’

IF(Test-Path -path $Batscript)

{

Remove-Item $Batscript

}

$SSIDImport = Get-Content ‘D:\SSID.txt’

Foreach($SSID in $SSIDImport)

{

“nsrmm.exe -d -S $SSID -y $SSID | Out-File -filepath $Batscript -Force -Append -Encoding ascii

}

‘nsrim.exe -X’ | Out-File -FilePath $Batscript –Append -encoding ascii

After this change, everything worked perfectly.

 

Advertisement
 
1 Comment

Posted by on March 31, 2016 in ICT, Microsoft, Powershell

 

Tags: , , , , , , , , ,

Microsoft – Troubleshooting Key Management Service (KMS) activation

Today I helped a colleague troubleshoot a couple of systems were unable to activate using Key Management Service (KMS). Basically for this situation it boiled down to this:

Determine for the KMS service

  1. Which server is hosting the KMS service.If an SRV record has been added for KMS DNS auto discovery, run from CMD: nslookup -type=srv _vlmcs._tcp
  2. If the server hosting the KMS is functioning correctly:
  • Check if the server is up and running.
  • Check if the “Software Protection” service (sppsvc) is running.
  • Verify if the KMS service is listening on port 1688: telnet localhost 1688
  • Verify the KMS status. Run from CMD: slmgr.vbs /dli
  • Verify if a KMS key is installed and activated.
  • Verify if the minimum threshold for activation is being met.
  • Verify if other clients are able to activate using KMS. Even though the output of “slmgr.vbs /dli” gives you an indication, you can use the “Volume Activation Management Tool” (VAMT) for more insight and functionality.
  • Verify that a VLK key is being used.

For clients that are not able to activate

  • Verify if the correct KMS server can be resolved correctly:
    nslookup -type=srv _vlmcs._tcp
  • Verify if the KMS can be contacted:
    telnet <KMS FQDN or IP> 1688

    •  If this is not the case, perform a traceroute to determine potential causes. Reasons could include:
      • No default gateway configured on the client to reach the KMS.
      • No route configured on the client to reach the KMS.
      • Firewall on the client is blocking the traffic.
      • Firewall on the server is blocking the traffic.
      • If it is a VM, the virtual network might be misconfigured.
      • Routing on the network is not correct.
      • Firewall on the network is blocking traffic.
  • Clear any previous (mis)configuration: slmgr.vbs /ckms
  • Attempt activation: slmgr.vbs /ckms

NOTE: If you have lots of systems where you need to clear configuration and then attempt activation, you can also perform slmgr.vbs on remote computers using:
slmgr.vbs TargetComputerName [username] [password] /parameter [options]

Additional information

If you haven’t been able to resolve the issue, you might want to take a look here:

 

Tags: , , , , , , , , , , , , , , , , , , ,

 
%d bloggers like this: