IPv6 Disable ISATAP and 6to4

email me

netsh int ipv6 isatap set state disabled
netsh int ipv6 6to4 set state disabled
netsh interface teredo set state disable


To re-enable isatap teredo 6to4

netsh interface teredo set state type default

 

Other important commands

netsh interface isatap set router The_EDGE1_IP_Address (example, 10.0.0.2)
netsh interface isatap set state enabled
netsh interface teredo set state enterpriseclient

Deleting All Files Starting with a Tilde

email me

Be careful with this!

You can delete all files meeting a certain criteria or pattern. For example, if you wanted to delete all files on your computer starting with a tilde:

del /s /q “~*.*”

 

You could have as easily done:

del /s /q “*.tmp”
del /s /q “*.cmd”
del /s /q “5*.*”
del /s /q “my*.*”
del /s /q “*.docx*”

del /s /q — the /s is cycle through subdirectories and the /q is quiet mode

Robocopy – Moving My Documents

email me

Moving My Documents to a subfolder

The For command will cycle the the My Documents folder performing the robocopy command on each item. FOR conditionally performs any command or a specified sequence of commands multiple times.

for /d %%Y in (Sta??) do (for /f “usebackq tokens=*” %%U in (‘dir /b /ad “%%~Y\*”‘) do (robocopy.exe “%%~Y\%%~U” “%%~Y\%%~U\Documents” /e /move /xd “Documents”))

Reference: http://ss64.com/nt/for.html   http://ss64.com/nt/robocopy.html

PowerShell Archive Users Not Logged in 90 Days

email me

$DaysInactive = (Get-Date).AddDays(-90)
$Leavers = Get-ADUser -Filter { Enabled -eq $false -and LastLogonTimeStamp -ge $DaysInactive } -SearchBase “OU=Employees,DC=DomainName,DC=com” -Properties HomeDirectory

ForEach ($User in $Leavers) {

$ArchivePath = [io.path]::Combine(“Z:\EmployeesArchived”,$User.SamAccountName)

If (Test-Path $User.HomeDirectory) {
Move-Item –Path $User.HomeDirectory -Destination $ArchivePath -Force
}

}

iTunes 12.2.2.25 Silent Install

email me

Part of the sequence script

c:\windows\system32\msiexec.exe /i “%CD%\AppleApplicationSupport.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CD%\AppleApplicationSupport64.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CD%\AppleMobileDeviceSupport64.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CD%\Bonjour64.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CD%\AppleSoftwareUpdate.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CD%\iTunes6464.msi” /qn /norestart IAcceptLicense=Yes ALLUSERS=1 DESKTOP_SHORTCUTS=1 INSTALL_ASUW=0 NO_ASUW=1
“%CurDir%\copytoallprofiles_7.vbs”

The copytoallprofiles_7.vbs script – cycles through profiles to copy custom settings

If the iTunesPrefs.xml isn’t working for you, take a look at com.apple.iTunes.plist. Apple loves to sneak in new ways of storing configs.

on error resume next

Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Const HKEY_LOCAL_MACHINE = &H80000002
Const OverwriteExisting = TRUE
Source1 = "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\apps\Apple\iTunes\12.2.2.25\<strong>iTunesPrefs.xml</strong>"

'SETS CURRENT DIRECTORY TO VARIABLE
strCurrentDirectory = objShell.CurrentDirectory

on error resume next
'LSource1 = strCurrentDirectory & "\iTunesPrefs.xml"
'LSource2 = strCurrentDirectory & "\First Run"

'Target is dynamic is assigned below

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
on error resume next
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
Const POPUP_TITLE = "User To SID Conversion"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount = objWMIService.Get("Win32_SID.SID='" & objSubkey & "'")
strUser = objAccount.AccountName
'strDomain = objAccount.ReferencedDomainName'returns referenced domain

'DISPLAY PROFILE NAME & SID
objSubkey = trim(objSubkey)'trims whitespace
strUser = trim(strUser)'trims whitespace
'msgbox "objSubkey: " & objSubkey'returns SID
'msgbox strUser'returns username

'LOGIC TO DETERMINE IF REGISTRY ACCOUNT IS TO BE LOADED
if strUser = "SYSTEM" then strUser=""
if strUser = "LOCAL SERVICE" then strUser=""
if strUser = "NETWORK SERVICE" then strUser=""
if strUser = "ADMINISTRATOR" then strUser=""

if strUser &lt;&gt; "" then
on error resume next
objShell.Run "%comspec% /c md " & chr(34) & "C:\users\" & strUser & "\AppData\Roaming\Apple Computer\iTunes" & chr(34),0,false
Wscript.Sleep 1000
'path for local users
Target1 = "C:\users\" & strUser & "\AppData\Roaming\Apple Computer\iTunes\"
'path for redirected users


objFSO.CopyFile Source1, Target1, OverwriteExisting

'FAILSAFE
on error resume next
strMainSource = "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\apps\Apple\iTunes\12.2.2.25"
strMainTarget1 = strValue & "\AppData\Roaming\Apple Computer\iTunes"
Wscript.Sleep 1000

'vbcsript copy
objFSO.CopyFile "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\apps\Apple\iTunes\12.2.2.25\<strong>iTunesPrefs.xml</strong>", strValue & "\AppData\Roaming\Apple Computer\iTunes\", OverwriteExisting

Wscript.Sleep 1000

'shell copy
'for local users
objShell.Run "%comspec% /c copy /y " & chr(34) & strMainSource & "\iTunesPrefs.xml" & chr(34) & " " & chr(34) & strMainTarget1 & "\iTunesPrefs.xml" & chr(34),0,true
objShell.Run "%comspec% /c copy /y " & chr(34) & strCurrentDirectory & "\iTunesPrefs.xml" & chr(34) & " " & chr(34) & strMainTarget1 & "\iTunesPrefs.xml" & chr(34),0,true

'added for redirected users
'objShell.Run "%comspec% /c copy /y " & chr(34) & strCurrentDirectory & "\iTunesPrefs.xml" & chr(34) & " " & chr(34) & Target2 & "\iTunesPrefs.xml" & chr(34),0,true
Wscript.Sleep 1000

end if

Next