SCCM – Change Client Connection from Intranet to Internet

email me

Use this method—which can easily be scripted—to change the SCCM client connectivity type from Intranet to Always Internet. I found this to be useful when setting up our remote computers to be directed to our DMZ-PKI (a single public-facing server). Once this is set, it doesn’t matter if the users are on site or off site, they are managed by the DMZ endpoint.

Why do this? Due to the complexities of some networks, when remote users travel to an on site facility, [sometimes] their workgroup joined computers will not automatically detect and switch to the local SCCM distribution point, which causes the machines to fall into a non-managed state—this solution prevents that from happening. The computers are always managed through the DMZ. This cuts down on management complexity, DNS connectivity issues associated with remote computers, and guarantees machines remain managed.

 
:: Apply Reg Key
Reg add “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\CCM\Security” /v ClientAlwaysOnInternet /t reg_dword /d 1 /f

:: Restart CM Service
Sc stop CcmExec

Sc start CcmExec


Screenshot

 

Notes

Set Always Internet using ccmsetup

ccmsetup.exe /native SMSSITECODE=ABC CCMALWAYSINF=1 CCMHOSTNAME=HOSTCOMPUTERNAME SMSMP=SCCMMPSERVER SMSSIGNCERT=SITESIGNINGCERT

 

SCCM – Return MP Candidate Information

email me

PowerShell Command

Get-WmiObject -namespace root\ccm\locationservices -class SMS_ActiveMPCandidate


Output

__GENUS : 2
__CLASS : SMS_ActiveMPCandidate
__SUPERCLASS :
__DYNASTY : SMS_ActiveMPCandidate
__RELPATH : SMS_ActiveMPCandidate.MP=”xyz.abc.com”,MPBGRFallbackType=”None”,Type=”Internet”
__PROPERTY_COUNT : 14
__DERIVATION : {}
__SERVER : TEST-COMPUTER
__NAMESPACE : ROOT\ccm\locationservices
__PATH : \\TEST-COMPUTER\ROOT\ccm\locationservices:SMS_ActiveMPCandidate.MP=”xyz.abc.com”,MPBGRFallbackTy
pe=”None”,Type=”Internet”
Capabilities : <Capabilities SchemaVersion=”1.0″><Property Name=”SSL” Version=”1″/><Property Name=”SSLState”
Value=”63″/></Capabilities>
Index : 1
Locality : 0
MasterSiteCode :
MP : xyz.abc.com
MPBGRFallbackType : None
MPFallbackTime : 0
Protocol : OS
Reserved1 :
Reserved2 :
SiteCode :
State :
Type : Internet
Version : 8634
PSComputerName : Test-Computer

 

Or, return just the MP on Internet

(Get-WmiObject -Namespace Root\Ccm\LocationServices -Class SMS_ActiveMPCandidate | Where-Object {$_.Type -eq "Internet"}).MP

C# – Test String for Palindrome

email me

using System;

class Program
{
public static void Main()
{
string userString;

Console.WriteLine("Enter a word:\n");
userString = Convert.ToString(Console.ReadLine());
Console.WriteLine("\nWord is = {0}", userString);

string revString = Reverse(userString);
Console.WriteLine("Its reverse is = {0}", revString);

if (userString == revString)
Console.WriteLine("\nWord is a palindrome.\n");
else
Console.WriteLine("\nWord is not a palindrome.\n");

Console.ReadLine();
}

public static string Reverse(string s)
{
char[] charArray = s.ToCharArray();
Array.Reverse(charArray);
return new string(charArray);
}
}


Output


Notes

Some further research for you…measuring the efficiency of different reverse methods.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
public static string ReverseUsingArrayClass(string text)
{
char[] chars = text.ToCharArray();
Array.Reverse(chars);
return new string(chars);
}

public static string ReverseUsingCharacterBuffer(string text)
{
char[] charArray = new char[text.Length];
int inputStrLength = text.Length - 1;
for (int idx = 0; idx &lt;= inputStrLength; idx++) { charArray[idx] = text[inputStrLength - idx]; } return new string(charArray); } public static string ReverseUsingStringBuilder(string text) { if (string.IsNullOrEmpty(text)) { return text; } StringBuilder builder = new StringBuilder(text.Length); for (int i = text.Length - 1; i &gt;= 0; i--)
{
builder.Append(text[i]);
}

return builder.ToString();
}

private static string ReverseUsingStack(string input)
{
Stack&lt;char&gt; resultStack = new Stack&lt;char&gt;();
foreach (char c in input)
{
resultStack.Push(c);
}

StringBuilder sb = new StringBuilder();
while (resultStack.Count &gt; 0)
{
sb.Append(resultStack.Pop());
}
return sb.ToString();
}

public static string ReverseUsingXOR(string text)
{
char[] charArray = text.ToCharArray();
int length = text.Length - 1;
for (int i = 0; i &lt; length; i++, length--)
{
charArray[i] ^= charArray[length];
charArray[length] ^= charArray[i];
charArray[i] ^= charArray[length];
}

return new string(charArray);
}

static void Main(string[] args)
{
int cycleCount = 20;

string testString = string.Join(";", new string[] {
new string('l', 10),
new string('e', 10),
new string('v', 10),
new string('e', 10),
new string('l', 10),
});

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();

for (int i = 0; i &lt; cycleCount; i++)
{
Console.WriteLine(ReverseUsingCharacterBuffer(testString));
}
stopwatch.Stop();
Console.WriteLine("ReverseUsingCharacterBuffer: " + stopwatch.ElapsedMilliseconds + "ms\n");

stopwatch.Reset();
stopwatch.Start();
for (int i = 0; i &lt; cycleCount; i++)
{
Console.WriteLine(ReverseUsingArrayClass(testString));
}
stopwatch.Stop();
Console.WriteLine("ReverseUsingArrayClass: " + stopwatch.ElapsedMilliseconds + "ms\n");

stopwatch.Reset();
stopwatch.Start();
for (int i = 0; i &lt; cycleCount; i++)
{
Console.WriteLine(ReverseUsingStringBuilder(testString));
}
stopwatch.Stop();
Console.WriteLine("ReverseUsingStringBuilder: " + stopwatch.ElapsedMilliseconds + "ms\n");

stopwatch.Reset();
stopwatch.Start();
for (int i = 0; i &lt; cycleCount; i++)
{
Console.WriteLine(ReverseUsingStack(testString));
}
stopwatch.Stop();
Console.WriteLine("ReverseUsingStack: " + stopwatch.ElapsedMilliseconds + "ms\n");

stopwatch.Reset();
stopwatch.Start();
for (int i = 0; i &lt; cycleCount; i++)
{
Console.WriteLine(ReverseUsingXOR(testString));
}
stopwatch.Stop();
Console.WriteLine("ReverseUsingXOR: " + stopwatch.ElapsedMilliseconds + "ms\n");

Console.ReadKey();
}
}
}

C++ String Rotation

email me
#include "stdafx.h"
#include <iostream>

using namespace std;

void Rotate(string s, int len);

int main() {
char s[20];

// Input
cout << "Enter string: "; cin >> s;
string t = s;

if (t.length() != 0)
{
cout << "\n------------\n";
Rotate(t, t.length());
cout << "\n------------";
}
else
cout << "Missing input!";

getchar(); getchar();

return 0;
}

void Rotate(string s, int len)
{
static int i = 0;
cout << "\"";

for (int j = i; j<len; ++j)
{
cout << s.at(j);
}

for (int k = 0; k<i; ++k)
{
cout << s.at(k);
}
cout << "\"";
i++;

if (i<len)
{
cout << endl;
Rotate(s, len);
}
}


Output

SCCM – Fix Software Center Shortcut

email me

After client update, Software Center shortcut is pointing to old/wrong location. Fix by running this Powershell Script.

$linkPath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft System Center\Configuration Manager\Software Center.lnk"
$object = New-Object -COM WScript.Shell
$shortcut = $object.CreateShortcut($linkPath)
$shortcut.TargetPath = "C:\Windows\CCM\ClientUX\SCClient.exe"
$shortcut.Save()

Azure – CLI – Create Website in Azure Cloud Shell

email me

Azure Cloud Shell?

Create Website

From Cloud Shell, run this az vm extension set command to download and execute a PowerShell script that installs IIS and configures a basic home page.

az vm extension set \
--resource-group 79fdb1a1-c11e-4716-8a08-f9c4d710ed47 \
--vm-name myVM \
--name CustomScriptExtension \
--publisher Microsoft.Compute \
--settings '{"fileUris":["https://raw.githubusercontent.com/MicrosoftDocs/mslearn-welcome-to-azure/master/configure-iis.ps1"]}' \
--protected-settings '{"commandToExecute": "powershell -ExecutionPolicy Unrestricted -File configure-iis.ps1"}'

 

Set up Firewall

Run this az vm open-port command to open port 80 (HTTP) through the firewall.

az vm open-port \
--name myVM \
--resource-group 79fdb1a1-c11e-4716-8a08-f9c4d710ed47 \
--port 80

 

Verify Site

az vm show \
--name myVM \
--resource-group 79fdb1a1-c11e-4716-8a08-f9c4d710ed47 \
--show-details \
--query [publicIps] \
--output tsv

 

Check the page in a browser…

 

Notes

Install the Azure CLI on Windows

Azure Az Commands

Official Documentation by Microsoft

Azure – CLI – Create VM in Azure Cloud Shell

email me

Azure Cloud Shell?

Create VM

USERNAME=azureuser
PASSWORD=$(openssl rand -base64 32)

az vm create \
--name myVM \
--resource-group 79fdb1a1-c11e-4716-8a08-f9c4d710ed47 \
--image Win2016Datacenter \
--size Standard_DS2_v2 \
--location eastus \
--admin-username $USERNAME \
--admin-password $PASSWORD


Verify VM

az vm get-instance-view \
--name myVM \
--resource-group 79fdb1a1-c11e-4716-8a08-f9c4d710ed47 \
--output table

Output

 

Notes

Install Azure CLI for Windows

Azure Az Commands

Official Documentation by Microsoft

Microsoft Quickstart: Create a Windows virtual machine with the Azure CLI

Java Client 8 – 201 and 202

email me

The latest Java Client is available here:
https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

 

Silent Installation

JavaDownload.exe INSTALL_SILENT=1 STATIC=0 AUTO_UPDATE=0 WEB_JAVA=1 WEB_JAVA_SECURITY_LEVEL=H WEB_ANALYTICS=0 EULA=0 REBOOT=0

 

64 Bit

Version
8.0.2020.8

Size
73.6 MB

Registry
REG.exe ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F64180202F0}” /v “Publisher” /t REG_SZ /d “YourDesktopManagementSoftware—example: SCCM” /f

Uninstall
msiexec /x{26A24AE4-039D-4CA4-87B4-2F64180202F0}


32 Bit

Version
8.0.2020.8

Size
65.7 MB

Registry
REG.exe ADD “HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F32180202F0}” /v “Publisher” /t REG_SZ /d “YourDesktopManagementSoftware—example: SCCM” /f

Uninstall
msiexec /x{26A24AE4-039D-4CA4-87B4-2F32180202F0}