import os
os.remove(“/Users/Shared/TextFile.txt”)
Author: MrNetTek
Python – Read Lines from Text File
Tested on a Mac, 10.12.6.
import os.path textFile = "/Users/Shared/TextFile.txt" doesFileExist=os.path.isfile(textFile) if doesFileExist == True: file = open(textFile,"r") lines=file.read().splitlines() global line1 global line2 line1 = lines[0] line2 = lines[1] file.close()
Notes
Mode | Description |
---|---|
‘r’ | This is the default mode. It Opens file for reading. |
‘w’ | This Mode Opens file for writing. If file does not exist, it creates a new file. If file exists it truncates the file. |
‘x’ | Creates a new file. If file already exists, the operation fails. |
‘a’ | Open file in append mode. If file does not exist, it creates a new file. |
‘t’ | This is the default mode. It opens in text mode. |
‘b’ | This opens in binary mode. |
‘+’ | This will open a file for reading and writing (updating) |
Mac – Create a Daemon to Load App
Step 1 – Create a plist file. Save as something like com.TheAppName.plist
<?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>app.TheAppName</string> <key>ProgramArguments</key> <array> <string>/usr/bin/open</string> <string>/Applications/TheAppName.app</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <false/> <key>LaunchOnlyOnce</key> <false/> <key>StartInterval</key> <integer>3600</integer><!-- seconds --> </dict> </plist>
Step 2 – Copy plist to /System/Library/LaunchDaemons/
Step 3 – Load the daemon
sudo launchctl load -w /System/Library/LaunchDaemons/com.TheAppName.plist
Step 4 – Log off & Log on to test
Azure – Replace Package Owner with Domain User Owner
* 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
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
Google Chrome – 72.0.3626.109
Download
New Chrome browser is available here:
https://enterprise.google.com/intl/en_version/chrome/chrome-browser/ mirror
Size
54.4 MB
Product Code
{462C0125-29AE-348F-B87F-E65FE8AF6A66}
Silent Install
setup.msi /quiet /norestart
Notes