{
grep '^a.*e$' file
This means: look for those lines starting (^
) with a
, then 0 or more characters and finally and e
at the end of the line ($
).
grep -riL done *
Search for all of the file names that do not contain the text "done" (recursive, case insensitive)
grep -ri "p 2425" *
Useful for searching Radmind command files for transcripts (p) from a specific year (2425) (recursive, case insensitive)
https://www.cs.colostate.edu/helpdocs/vi.html
(The text in this case is "1 row"
split -p '^1 row.*' Software\ on\ Refreshing\ Windows\ Computers.txt
osascript -e ‘tell application “safari” to quit’
#!/bin/bash
sudo -s
ditto -ck foldername foldername.zip
diskutil cs list
copy 1st GUID
diskutil cs delete GUID
after deploying image but NOT restarting, open a terminal window from the utilities menu
defaults read /Volumes/Macintosh\ HD/var/kace/ds/imageinfo.plist
defaults write /Volumes/Macintosh\ HD/var/kace/ds/imageinfo.plist ImageHostname XXXX###-##XX
remove a from a .dmg or .zip before unpacking
from a terminal window
xattr -c nameofthe.dmg
codesign -dv /path/to/kext
Opening apps Apple can’t scan for malware
In terminal, type sudo -s
cd to the directory where the apps is
type xattr -c appname.app
Sooooo. I forgot to talk to you about something, Sam. I'm going to paste it here so we can chat asynchronously before I go on vacation.With the Windows K1000 packages that need updating, we're going to rewrite the install.bat files (and any other related files) to use environment variables instead of c:\This needs to happen in the body of the files and the command at the top that gets you to the native command prompt. I've updated the wiki page of code snippits:https://wiki.carleton.edu/display/itskb/Reb%27s+Handy+Bits+of+Code#Reb'sHandyBitsofCode-GettingtotheNativecmdpromptAnd here is one of the office install.bat files as an example:
======================================================== @echo off if not exist "%windir%\sysnative\cmd.exe" goto :gonenative echo Relaunching with x64 cmd.exe... "%windir%\sysnative\cmd.exe" /C "%~dpnx0" goto :EOF :gonenative REM ---paste the rest of your batch code below this line--- ======================================================== If exist "%ProgramFiles%\KACE\ds\office rd /s /q "%ProgramFiles%\KACE\ds\office\" echo Copying Office Repo xcopy office\Office-2023.05.11\office "%ProgramFiles%\KACE\ds\office" /e /c /h /i /r /y /z echo Installing Office "%ProgramFiles%\KACE\ds\office\setup.exe" /configure "%ProgramFiles%\KACE\ds\office\2021uon-2022.05.11.xml" cscript.exe "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" /sethst:kms3.ads.carleton.edu cscript.exe "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" /act reg delete HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run /v TeamsMachineInstaller /f |
You can see the Windows environment variables by typing SET in the command prompt.Some of them resolve to the same place, so for c:\ProgramData, let's use %ProgramData%, not %ALLUSERSPROFILE%. For c:\Program Files, let's use %ProgramFiles% and not %ProgramW6432%. Let's use %SystemDrive% and not %HOMEDRIVE% and %windir% not %Systemroot%. It's probably most important that we do this for commonly used applications.
After imaging (and NOT auto rebooting), return to main menu. Go into Recovery and open Command Prompt.
i:\imaging\bin\changeimagehostname.cmd
then press enter and input the new host name as prompted
Batch File Reference
http://steve-jansen.github.io/guides/windows-batch-scripting/index.html
IF, no ELSE
if exist %SystemRoot%\system32\Macromed\Flash\flash.ocx %SystemRoot%\system32\Macromed\Flash\UninstFl.exe -q -u %SystemRoot%\system32\Macromed\Flash\flash.ocx if exist %SystemRoot%\system32\Macromed\Flash\flash6.ocx %SystemRoot%\system32\Macromed\Flash\UninstFl.exe -q -u %SystemRoot%\system32\Macromed\Flash\flash6.ocx |
IF, ELSE
If Exist C:\Windows\SysWOW64 ( do some stuff for 64-bit Windows do maybe another line of stuff ) ELSE ( do some other stuff for 32-bit Windows and maybe another line of stuff ) |
IF, ELSE, GOTO
If Exist C:\Windows\SysWOW64 ( GOTO x64 ) ELSE ( GOTO x86 ) :x64 do some stuff GOTO END :x86 do some stuff GOTO END :END |
CMD:
Diskpart
select disk 0
clean
convert gpt
Powershell:
Clear-Disk -Number 0
Initialize-Disk -Number 0 -PartitionStyle GPT
CMD:
ver | find "6.3" >nul && goto WIN8
This will detect Windows 8 and goto a section in a batch file for Win8
Powershell:
$Bitness = Get-WMIObject win32_operatingsystem
$Bitness.OSarchitecture
or
(Get-WMIObject win32_operatingsystem).OSarchitecture
Get-WindowsEdition -Verbose -Online
if /i "%WMICModel:~0,7%"=="20074DU" set TP=y
Detects Model = 20074DU and sets a variable
CMD:
taskkill /F /IM iTunesHelper.exe
PowerShell:
Stop-Process -Force -Name iTunesHelper
CMD:
net stop "Apple Mobile Device"
net stop "Intel(R) Management and Security Application Local Management Service"
Powershell:
Stop-Service -Force -DisplayName "Apple Mobile Device"
Stop-Service -Force -DisplayName "Intel(R) Management and Security Application Local Management Service"
PING -n 30 127.0.0.1>NUL
Account Stuff (Powershell)
32-bit K1000
%systemdrive%\Windows\sysnative\WindowsPowerShell\v1.0 powershell.exe -Command "Set-LocalUser -Name 'NAME' -PasswordNeverExpires $true"
64-bit K1000
$(KACE_SYS_DIR)\WindowsPowershell\v1.0 powershell.exe -Command "Set-LocalUser -Name 'NAME' -PasswordNeverExpires $true"
32-bit K1000
%systemdrive%\Windows\sysnative\WindowsPowerShell\v1.0 powershell.exe -Command "New-LocalUser -Name 'NAME' -Password (ConvertTo-SecureString -String 'PASSWORD' -AsPlainText -Force); if($?) {Set-LocalUser -Name 'NAME' -PasswordNeverExpires $true}"
64-bit K1000
$(KACE_SYS_DIR)\WindowsPowershell\v1.0 powershell.exe -Command "New-LocalUser -Name 'NAME' -Password (ConvertTo-SecureString -String 'PASSWORD' -AsPlainText -Force); if($?) {Set-LocalUser -Name 'NAME' -PasswordNeverExpires $true}"
32-bit K1000
%systemdrive%\Windows\sysnative\WindowsPowerShell\v1.0 powershell.exe -Command "New-LocalUser -Name 'NAME' -Password (ConvertTo-SecureString -String 'PASSWORD' -AsPlainText -Force); if($?) {Set-LocalUser -Name 'NAME' -PasswordNeverExpires $true}; if($?) {Add-LocalGroupMember -Group 'Administrators' -Member 'NAME'}"
64-bit K1000
$(KACE_SYS_DIR)\WindowsPowershell\v1.0 powershell.exe -Command "New-LocalUser -Name 'NAME' -Password (ConvertTo-SecureString -String 'PASSWORD' -AsPlainText -Force); if($?) {Set-LocalUser -Name 'NAME' -PasswordNeverExpires $true}; if($?) {Add-LocalGroupMember -Group 'Administrators' -Member 'NAME'}"
32-bit K1000
%systemdrive%\Windows\sysnative\WindowsPowerShell\v1.0 powershell.exe -Command "Add-LocalGroupMember -Group 'Administrators' -Member 'NAME'"
64-bit K1000
%systemdrive%\Windows\sysnative\WindowsPowerShell\v1.0 powershell.exe -Command "Remove-LocalGroupMember -Group 'Administrators' -Member 'NAME'"
32-bit K1000
%systemdrive%\Windows\sysnative\WindowsPowerShell\v1.0 powershell.exe -Command "Enable-LocalUser -Name 'NAME'"
64-bit K1000
$(KACE_SYS_DIR)\WindowsPowershell\v1.0 powershell.exe -Command "Enable-LocalUser -Name 'NAME'"
32-bit K1000
%systemdrive%\Windows\sysnative\WindowsPowerShell\v1.0 powershell.exe -Command "Disable-LocalUser -Name 'NAME'"
64-bit K1000
$(KACE_SYS_DIR)\WindowsPowershell\v1.0 powershell.exe -Command "Disable-LocalUser -Name 'NAME'"
32-bit K1000
%systemdrive%\Windows\sysnative\WindowsPowerShell\v1.0 powershell.exe -Command "Set-LocalUser -Name 'NAME' -Password (ConvertTo-SecureString -String 'PASSWORD' -AsPlainText -Force)"
64-bit K1000
$(KACE_SYS_DIR)\WindowsPowershell\v1.0 powershell.exe -Command "Set-LocalUser -Name 'NAME' -Password (ConvertTo-SecureString -String 'PASSWORD' -AsPlainText -Force)"
msiexec.exe /i ENX7Inst.msi USERCANAPPLYUPDATES=F /qb
msiexec.exe /update ENX7Update.msp /qb
"%~dp07za.exe" x -y -o"C:\Program Files (x86)\NotePadPlusPlus" "%~dp0npp.6.6.6.bin.7z"
CMD:
If Exist C:\Windows\SysWOW64 ( do some stuff for 64-bit Windows ) ELSE ( do some other stuff for 32-bit Windows ) |
$x = Get-WmiObject win32_operatingsystem if( $x.OSArchitecture -eq "64-bit") { do stuff in 64-bit Windows } else { do some stuff in 32-bit Windows } |
======================================================== @echo off if not exist "%windir%\sysnative\cmd.exe" goto :gonenative echo Relaunching with x64 cmd.exe... "%windir%\sysnative\cmd.exe" /C "%~dpnx0" goto :EOF :gonenative REM ---paste the rest of your batch code below this line--- ======================================================== |
/e /c /i /h /r /y /z
The solution is quite simple. Using a VM or a system for testing, install the software and check off "Always Trust software from [Publisher]". What this does is place a certificate in the local computers certificate store that will rid future installs from Novell of this dialogue. What we do then, is export the certificate and put it into your install script. Follow the below to conquer this problem:
In your test environment, install the program fully and be sure to click 'Always trust software from [Publisher]
Run certmgr.msc and navigate to Trusted Publishers then Certificates
The certificate from the publisher will show up there. Right click and click All Tasks -> Export. Save the file.
You now have the certificate from the test environment. You need to import this to the computers being deployed to prior to the install. Simply run the following command in your install script before the program install:
certutil -addstore "TrustedPublisher" MyCertificate.cer
echo Attempting to uninstall Endnote X6
MsiExec.exe /x{86B3F2D6-AC2B-0016-8AE1-F2F77F781B0C} /qn
You can find this code in HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
FOR /D %%G in ("c:\Program Files\R\*") Do "%%G\unins000.exe" /SILENT
FOR /D %%G in ("c:\Program Files (X86)\R\*") Do "%%G\unins000.exe" /SILENT
for /D %%f in ("c:\Program Files\Inkscape"*) do rd "%%f" /s /q
FOR /D %%G in ("c:\Users\*") Do del "%%G\Desktop\EditPad Lite 7.lnk"
If you know the location of the shortcut, you can do the following:
del /F /Q "yourpathhere"
i.e. del /F /Q "c:\Users\Public\Desktop\Evernote.lnk"
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\NotepadPlusPlus"
xcopy "startmenu\notepad++.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\NotepadPlusPlus" /e /c /i /h /r /y /z
netsh advfirewall firewall add rule name="Google Earth" dir=in action=allow program="C:\Program Files (x86)\Google\Google Earth\client\googleearth.exe"
reg.exe import registryfile.reg /reg:64
Verify that
HKLM64\Software\path to your stuff
reg delete HKLM\Software\wOW6432Node\Inkscape /f
reg delete HKLM\Software\Inkscape /f
/wiki/spaces/itskb/pages/26116466
https://developers.google.com/apps-script/articles/removing_duplicates
Script Text
function removeDuplicates() { var sheet = SpreadsheetApp.getActiveSheet(); var data = sheet.getDataRange().getValues(); var newData = new Array(); for(i in data){ var row = data[i]; var duplicate = false; for(j in newData){ if(row.join() == newData[j].join()){ duplicate = true; } } if(!duplicate){ newData.push(row); } } sheet.clearContents(); sheet.getRange(1, 1, newData.length, newData[0].length) .setValues(newData); } |
=IF(LEFT(O2,4)="ADS\", RIGHT(O2,LEN(O2)-4), O2) |
=B2&"@carleton.edu" |
=match(H1,indirect("PilotUsers!K:K"),0) |
=ArrayFormula(FILTER('2018.11.09 All'!A:A,ISERROR(match('2018.11.09 All'!A:A,'2018.10.09 All'!A:A,0)))) |
=VLOOKUP(A3, '2018.11.09 All'!A:D, 4, FALSE) |