Powershell cmdlet’s from OpenAPI

I am building PS Cmdlet’s from an OpenAPI specifications. Here are pre-reqs.

apt update
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash
apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates gcc g++ make nodejs powershell dotnet-sdk-3.1
npm install -g autorest@beta

Group Policy RSSSAVER

I was testing rsssaver to deploy enterprise wide to have an information screen saver. In my testing rsssaver looks the best but does not work with Windows 7 and does not support multiple screens. I have not found a good replacement, but here is the GPO policy file that I used to centrally manage the configuration.

RSSSAVER.ADM

CLASS USER
CATEGORY Software
  POLICY rsssaver
  KEYNAME Software\rsssaver
    PART URLs EDITTEXT
    VALUENAME "URLs"
    END PART
    PART TTL EDITTEXT
    VALUENAME "TTL"
    END PART
    PART Color1 EDITTEXT
    VALUENAME "Color1"
    END PART
    PART Color2 EDITTEXT
    VALUENAME "Color2"
    END PART
    PART MipMap EDITTEXT
    VALUENAME "MipMap"
    END PART
  END POLICY
END CATEGORY

Fix Duplicate WSUS Ids

If you have an environment that that does not use SYSPREP you have a good chance that you will have duplicate WSUS IDs on your network and alot of system not patching properly.

These pair of scripts will query your WSUS DB and if the computer name does not match the WSUS id in the database it will reset the WSUS ID on the workstation.

wsusclientid.asp -> install on WSUS server

<%
susid = Request.QueryString("susid")
suscname = Request.QueryString("suscname")
connstring = "Driver={SQL Native Client};Server=localhost;Database=SUSDB;UID=wsusid;PWD=DBPASSWORD"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = connstring
objConn.Open

Set rs = objConn.execute ("select COUNT(ComputerTargetId) AS records from PUBLIC_VIEWS.vComputerTarget where (ComputerTargetID = '" & susid & "' and Name Like '" & suscname & "%');")

response.write rs("records")

rs.close

%>

susCLientID.vbs -> run as Startup Script

'stephen

'Check and correct duplicate sus client ids on the network

'this has a sister script on the wsus server to talk to.



'get susclientid

Set objRegistry = CreateObject("Wscript.shell")

Set WshNetwork = WScript.CreateObject("WScript.Network")

set oxmlhttp=createobject("msxml2.xmlhttp")



suscname = WshNetwork.ComputerName

susclientid = objRegistry.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\SusClientID")



oxmlhttp.open "GET", "http://wsus.SERVER.local/wsusclientid.asp?susid=" & susclientid & "&suscname=" & suscname, false

oxmlhttp.send ""

response = oxmlhttp.responseText

if (response = 0 ) then

 objRegistry.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\SusClientID"

 objRegistry.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\SusClientIdValidation"

 WScript.Sleep 10000

 objRegistry.run "net stop wuauserv"

 WScript.Sleep 10000

 objRegistry.run "net start wuauserv"

 WScript.Sleep 10000

 objRegistry.run "wuauclt /resetauthorization /detectnow"

 WScript.Sleep 10000
 objRegistry.run "wuauclt /r /reportnow"
 WScript.Sleep 10000
end if


stunnel on mac

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

        <key>Label</key>

        <string>org.stunnel.startup</string>

        <key>ProgramArguments</key>

        <array>

                <string>/opt/local/bin/stunnel</string>

        </array>

        <key>RunAtLoad</key>

        <true/>

</dict>

</plist>

I needed to have the macports version of stunnel run on startup.

Here is my config that i put into /Library/LaunchDaemons and named it org.stunnel.startup.plist

Avaya Backup and Restore on IIS 7.5

IIS 7.5 does not support Anonymous webdav PUTS which is required by Avaya phones and to properly backup. However there is a solution.

This will only Work on IIS 7.5.

  1. Uninstall or Disable webdav on the website or virtual directory.
  2. Create a empty rewrite rule as follows
    1. Requested URL: Matches the Pattern
    2. Using: Wildcards
    3. Pattern: *.txt
    4. Action Type: Rewrite
    5. Rewrite URL: avayaupload.php
  3. Put the script below into avayaupload.php
<?php
if ($_SERVER['REQUEST_METHOD'] == "PUT")
{ $f = fopen(basename($_SERVER['REQUEST_URI']), "w");
  $s = fopen("php://input", "r");
  while($kb = fread($s, 1024))
  { fwrite($f, $kb, 1024); }
  fclose($f);
  fclose($s);
  Header("HTTP/1.1 201 Created"); }
elseif ($_SERVER['REQUEST_METHOD'] == "GET")
{ readfile(basename($_SERVER['REQUEST_URI'])); }

?>

You are going to need PHP installed. The easiest way is to install it from here http://www.microsoft.com/web/downloads/platform.aspx

Make sure your BRURI is set and your BRAUTH is 0. A quick test is to use curl from a unix or mac machine. curl -T test.txt http://avayabackupserver/backupdir test.txt will be uploaded to the server if everything is configured correctly.

 

*UPDATE

Please note that this was written for IIS 7.5 in 2008 r2 not for IIS 7.0 in 2008.