Azure – Replace Package Owner with Domain User Owner

email me

* experimental

This is a script I wrote to change from the package owner, which only gives you the ability to manage the device policy in Intune, to an AD/AAD user, which gives you the ability to manage policies for both user and device. So, perform the bulk enrollment, and then run this script with your data.txt file. All devices showing Package as the owner will be updated with the specified user.

Code

Clear-Host

$ErrorActionPreference= 'silentlycontinue'

$item = $null
$line = $null

foreach($line in Get-Content C:\INTUNE\Data.txt) {
foreach ($item in $line)
{
$item = $line -split (",")
$DeviceName = $item[0]
$UserName = $item[1]

$x = Get-AzureADDevice -SearchString $DeviceName | Select Name -ExpandProperty ObjectId
$y = Get-AzureADUser -SearchString $UserName | Select Name -ExpandProperty ObjectId

Write-Host "Username: $UserName ::: $y"
Write-Host "Device: $DeviceName ::: $x"
Add-AzureADDeviceRegisteredOwner -ObjectId $x -RefObjectId $y
Get-AzureADDeviceRegisteredOwner -ObjectId $x
Add-AzureADDeviceRegisteredUser -ObjectId $x -RefObjectId $y
#Remove-AzureADDeviceRegisteredOwner -ObjectId $x -OwnerId $y
Write-Host ""

$x = ""
$y = ""
$DeviceName = ""
$UserName = ""
}
}

$item = $null
$line = $null


Data.txt file

PCName1, JohnDoe
PCName2, JaneDoe

 

Notes

Get-AzureADDevice
Get-AzureADUser
Add-AzureADDeviceRegisteredOwner
Get-AzureADDeviceRegisteredOwner
Add-AzureADDeviceRegisteredUser

 

Reg key

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo
—check out UserEmail reg value
—this value can be changed, which reflects the user on the Access work or school

Pascal – Iteration and Input

email me

Tested in Free Pascal.

Code

PROGRAM LoopAndInput (input, output);

CONST
    LoopLimit = 5;

VAR
    Index, Number, Sum : integer;
    Average : real;

BEGIN
    Sum := 0;
    FOR Index := 1 TO LoopLimit DO
        BEGIN
            writeln (#13#10'Enter number ', Index, ' of ', LoopLimit);
            readln (Number);
            Sum := Sum + Number
        END;
    Average := Sum / LoopLimit;
    writeln;
    writeln ('Average:', Average:5:0);
    writeln;
    readln;
  END.

 

Output

 


Notes

Syntax Highlighter

Online Compiler

Free Pascal compiler

Bash – Hello World

email me

Recommended Reading (click for Amazon link)

 

I used an online interpreter to test the code (as well as OS X). See notes.

Code

#!/bin/bash
echo "Hello, world!"


Output


Notes

Online Interpreter

To run in OS X:

Save as helloworld.sh on the desktop  — the .sh stands for shell, as in a shell script.

— Open a terminal window

— Drag helloworld.sh to terminal window

— Press Return

Skype for Desktop – 8.39.0.180

email me

Download

New Skype for Desktop (Windows) is available here:

https://go.skype.com/windows.desktop.download  mirror


Silent Install

setup.exe /VERYSILENT /SP- /NOCANCEL /NORESTART /SUPPRESSMSGBOXES /NOLAUNCH -ms


Uninstall

Reg Keys

“HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Skype_is1”

Command

“C:\Program Files (x86)\Microsoft\Skype for Desktop\unins000.exe” /SILENT

 

Notes

Disable Skype auto updates

Apple iTunes – 12.9.3.3

email me

Download

New iTunes app is available from here:

https://www.apple.com/itunes/download/win64


Contents of iTunes64Setup.exe
(using 7zip)


Size

256 MB


Command

iTunes64.msi /qn /norestart IAcceptLicense=Yes ALLUSERS=1 DESKTOP_SHORTCUTS=1 INSTALL_ASUW=0 NO_ASUW=1 SCHEDULE_ASUW=0


Notes

C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell -ExecutionPolicy Bypass -Command “Get-AppxPackage *AppleInc.iTunes* | Remove-AppxPackage”

msiexec /x “{56DDDFB8-7F79-4480-89D5-25E1F52AB28F}” /qn
msiexec /x “{5A659BE5-849B-484E-A83B-DCB78407F3A4}” /qn
msiexec /x “{F8060941-C0AB-4BCE-88AC-F2FDA2E9F286}” /qn
msiexec /x “{A30EA700-5515-48F0-88B0-9E99DC356B88}” /qn
msiexec /x “{5FA8C4BE-8C74-4B9C-9B49-EBF759230189}” /qn
msiexec /x “{D9D08A8F-5A03-486A-AD4D-3A438D521F8B}” /qn

Python – Simple Form, with Functions and Buttons

email me

Tested on a Mac > terminal > python script.py

import Tkinter as tk

root = tk.Tk()

# Function
counter = 0
def btn1():
button1.config(state="disabled")
counter = 0
def count():
global counter
counter += 1
label.config(text=str(counter))
label.after(1000, count)
count()

# setup form
root.title("Welcome to Commlink")
label = tk.Label(root, fg="dark green")
label.pack()

button1 = tk.Button(root, text='Start', width=25, command=btn1)
button1.pack()

button2 = tk.Button(root, text='Stop', width=25, command=root.destroy)
button2.pack()

root.mainloop()


Minimizing Window – Make Top Most


import Tkinter as tk
import webbrowser

# OPEN URL
new = 2
url = "http://google.com"
def btn3():
webbrowser.open(url,new=new)
command=quit(root)

# RUN TIMER
counter = 11
def btn1():
root.wm_state('iconic')
button1.config(state="disabled")
counter = 11
def count():
global counter
counter -= 1
if counter == 0:
retControl()
counter = 11
label1.config(text="")
root.deiconify()
return
label1.config(text=str(counter)+ " seconds")
label1.after(1000, count)
count()

# Return Snooze Button Control
def retControl():
button1.config(state="active")

# Kill Window
def quit(self):
self.destroy()
exit()

# form

root = tk.Tk()

root.title("Technology Notification")

# removes title bar
# root.overrideredirect(True)

label1 = tk.Label(root, fg="red")
label1.pack()

label2 = tk.Label(root, text = "Welcome to your first notification!\n\n")
label2.pack()

button1 = tk.Button(root, text='Snooze', width=25, command=btn1)
button1.pack()

button2 = tk.Button(root, text='Close', width=25, command=root.destroy)
button2.pack()

button3 = tk.Button(root, text='Open URL', width=25, command=btn3)
button3.pack()

# place window on top
root.attributes('-topmost', True)

root.mainloop()


Screenshot


Notes

Same code…

Tested in Windows > IDLE > script.py

C# – Flashing Taskbar Icon

email me

This is how you create those flashing Taskbar icons.

Form1.Designer.cs

Added to private void InitializeComponent (bottom of method)

FlashWindow.Tray(this);


Added under the private void InitializeComponent method

public static class FlashWindow
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FlashWindowEx(ref FLASHWINFO pwfi);

/// Stop flashing. The system restores the window to its original state.
public const uint FLASHW_STOP = 0;

/// Flash the window caption.
public const uint FLASHW_CAPTION = 1;

/// Flash the taskbar button.
public const uint FLASHW_TRAY = 2;

/// Flash both the window caption and taskbar button.
/// This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
public const uint FLASHW_ALL = 3;

/// Flash continuously, until the FLASHW_STOP flag is set.
public const uint FLASHW_TIMER = 4;

/// Flash continuously until the window comes to the foreground.
public const uint FLASHW_TIMERNOFG = 12;

[StructLayout(LayoutKind.Sequential)]
private struct FLASHWINFO
{

/// The size of the structure in bytes.
public uint cbSize;

/// A Handle to the Window to be Flashed. The window can be either opened or minimized.
public IntPtr hwnd;

/// The Flash Status.
public uint dwFlags;

/// The number of times to Flash the window.
public uint uCount;

/// The rate at which the Window is to be flashed, in milliseconds. If Zero, the function uses the default cursor blink rate.
public uint dwTimeout;
}

/// Flash the specified Window (Form) until it receives focus.
public static bool Flash(System.Windows.Forms.Form form)
{
// Make sure we're running under Windows 2000 or later
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, FLASHW_ALL | FLASHW_TIMERNOFG, uint.MaxValue, 0);
return FlashWindowEx(ref fi);
}
return false;
}

/// Flash the specified Window (form) for the specified number of times
public static bool Flash(System.Windows.Forms.Form form, uint count)
{
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, FLASHW_ALL, count, 0);
return FlashWindowEx(ref fi);
}
return false;
}

private static FLASHWINFO Create_FLASHWINFO(IntPtr handle, uint flags, uint count, uint timeout)
{
FLASHWINFO fi = new FLASHWINFO();
fi.cbSize = Convert.ToUInt32(Marshal.SizeOf(fi));
fi.hwnd = handle;
fi.dwFlags = flags;
fi.uCount = count;
fi.dwTimeout = timeout;
return fi;
}

/// helper methods
public static bool Tray(System.Windows.Forms.Form form)
{
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, FLASHW_TRAY, uint.MaxValue, 0);
return FlashWindowEx(ref fi);
}
return false;
}

public static bool TrayAndWindow(System.Windows.Forms.Form form)
{
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, FLASHW_ALL, uint.MaxValue, 0);
return FlashWindowEx(ref fi);
}
return false;
}

/// Stop Flashing the specified Window (form)
public static bool Stop(System.Windows.Forms.Form form)
{
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, FLASHW_STOP, uint.MaxValue, 0);
return FlashWindowEx(ref fi);
}
return false;
}

/// A boolean value indicating whether the application is running on Windows 2000 or later.
private static bool Win2000OrLater
{
get { return System.Environment.OSVersion.Version.Major >= 5; }
}

}


Notes

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-flashwindowex

https://www.pinvoke.net/default.aspx/user32/flashwindowex.html?diff=y