Search This Blog

Wednesday, December 09, 2015

Exchange 2013 disable auto-mapping of mailboxes with full access

Exchange 2013 disable auto-mapping of mailboxes with full access

# Get all mailboxes in the forest
$Mailboxes = Get-Mailbox -ResultSize unlimited -IgnoreDefaultScope
$ConfirmPreference = 'None'

# Iterate over each mailbox
foreach($Mailbox in $Mailboxes)
        # Try to run the example fix against the current $Mailbox
        $FixAutoMapping = Get-MailboxPermission $Mailbox |where {$_.AccessRights -eq "FullAccess" -and $_.IsInherited -eq $false}
        $FixAutoMapping | Remove-MailboxPermission -confirm $false
        $FixAutoMapping | ForEach {Add-MailboxPermission -Identity $_.Identity -User $_.User -AccessRights:FullAccess -AutoMapping $false}
        # Inform about the error if unsuccessful
        Write-Host "Encountered error: $($Error[0].Exception) on mailbox $($Mailbox.DisplayName)" -ForegroundColor Red

Monday, December 07, 2015

Deploy local printers to Windows XP

- Go to a computer without any printer installed, login as administrator and  install all the printers you need to deploy.
- download & run UTFG://printmig.exe go to Actions and click on Backup - save the cab file with the name
- download  UTFG://ListComps.exe and run listcomps.exe /D:MY_DOMAIN >> comps.txt
  (replace MY_DOMAIN with the domain you're in) edit the file comps.txt in order to remove unwanted computers, servers...
- in a command prompt type the following line: for /F %r in (comps.txt) do printmig.exe -i -r \\%r 
- now watch printmig spawning an instance for every computer and pushing the drivers to all of them
- enjoy a beer 

if before you want to remove ALL the old network printers you can use my (somehow pretty drastic) method of deleting.
Add this .vbs script to the user login or use psexec.exe to launch it:

------------------BEGIN HERE--------------------
' removepr.vbs - Windows NT Logon Script. 
' VBScript - Silently remove ALL network printers
' -----------------------------------------------------------------------'
Const ForReading = 1 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objNet = CreateObject("WScript.Network")
Set WshShell = CreateObject("WScript.Shell")
Set wmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set wmiNameSpace = wmiLocator.ConnectServer(objNet.ComputerName, "root\default")
Set objRegistry = wmiNameSpace.Get("StdRegProv")
Const HKEY_CLASSES_ROOT  = &H80000000
Const HKEY_CURRENT_USER  = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS         = &H80000003
strComputer = "."

' If this script already run once for this user, then EXIT
userprrf = WshShell.Environment("PROCESS")("UserProfile") 
'wscript.Echo userprrf
If (objFSO.FileExists(userprrf & "\sctwashere.txt")) Then
blah = "let's have some fun"
End If

' Deletes RegistryKey with all subkeys in Network printers
sPath = "Printers\Connections"
lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath)
Function DeleteRegEntry(sHive, sEnumPath)
' Attempt to delete key.  If it fails, start the subkey enumration process.
lRC = objRegistry.DeleteKey(sHive, sEnumPath)
' The deletion failed, start deleting subkeys.
If (lRC <> 0) Then
' Subkey Enumerator   
On Error Resume Next   
lRC = objRegistry.EnumKey(HKEY_CURRENT_USER, sEnumPath, sNames)   
For Each sKeyName In sNames      
If Err.Number <> 0 Then Exit For      
lRC = DeleteRegEntry(sHive, sEnumPath & "\" & sKeyName)   
On Error Goto 0
' At this point we should have looped through all subkeys, trying to delete the key again.   
lRC = objRegistry.DeleteKey(sHive, sEnumPath)
End If
End Function 
'Now let's recreate only the "root" Key we deleted before
objRegistry.CreateKey HKEY_CURRENT_USER,sPath

'Tell something to the user 
'with createobject("")  
'   .popup "All Network Printers are now erased.",1, "Printers Manager"
'end with
------------------END HERE--------------------

Wednesday, December 02, 2015

Configure DHCP options for Nortel IP Phones

In DHCP manager right-click the IPv4 and choose "Set Predefined Options" click "Add", name "blah", data type string, code 128, no description, click OK. Now, in the String field type: Nortel-i2004-A,,1,10. The BCM IP is here, the default port is 7000, the first parameter (action) is always 1, the second parameter (10) is the retry number and pay attention, there is a dot (.) at the end! 

Tuesday, December 01, 2015

Cloud Print on an old local printer

add printer in local cups. make sure it prints. some printers require loading a firmware stub. in my /etc/rc.d/rc.local I have the following line:
/usr/share/hplip/ -n -p HP_LaserJet_1020

open chrome as a normal user (in our case luser23)
go to chrome://devices/
click add printer. follow instructions.

create the following init script and make sure is executed at startup

cat /etc/init.d/cloudprint

# Start / Stop cloudprint daemon
# description:  Start / Stop cloudprint daemon
# chkconfig: 345 99 9
# Provides: cloudprint
# Default-Start: 3 4 5
# Short-Description:  Start / Stop cloudprint daemon
# Description:  Start / Stop cloudprint daemon

# Source function library.
. /etc/rc.d/init.d/functions

# config file

[ -r $CONF ] && . $CONF
[ -r $CONF ] || user=luser23
[ -r $CONF ] || options="/opt/google/chrome/chrome --type=service --enable-cloud-print-proxy --noservice-autorun --noerrdialogs --disk-cache-size=1 --media-cache-size=1 --disk-cache-dir=/tmp/chrome.$$ &"

# See how we were called.
case "$1" in
 gprintf "Starting cloudprint: "
 /usr/bin/su -l $user -c "$options" && success || failure
 gprintf "Shutting down cloudprint:"
 killproc chrome && success || failure
 status chrome
 $0 stop
 $0 start
 gprintf "Usage: %s\n" "$0 {start|stop|restart|status}"
 exit 1
exit 0

cat /etc/cloudprint.conf

options="/opt/google/chrome/chrome --type=service --enable-cloud-print-proxy --no-service-autorun --noerrdialogs --disk-cache-size=1 --media-cache-size=1 --disk-cache-dir=/tmp/chrome.$$ &"

or just add in /etc/rc.d/rc.local the following line:
su -l luser23 -c '/opt/google/chrome/chrome --type=service --enable-cloud-print-proxy --no-service-autorun --noerrdialogs --disk-cache-size=1 --media-cache-size=1 --disk-cache-dir=/tmp/chrome.$$ '

Blog Archive