Jump to content

Recommended Posts

Posted

A question...

 

I am thinking of running R-Desktop or similar on some linux boxes but in think client mode so it's full screen and runs at bootup.. Typically the RDS server will be one that we have hosted elsewhere. Linux machine will be setup to access the RDS server over the internet via RDP /RDesktop etc...

 

Im thinking about local printers... how would they work ? Could we install the printer locally on the Linux machine and would it pass through to the Remote session ?

 

Thanks

Posted

Install the printers on the server and map them to the printers based upon the client name (ie client X maps to printer X). You can do this using a login script.

OR

Use a print release system and only map one printer

OR

Use google cloud printing and map. This is probably the best option if you want to use ChromiumOS as your linux

 

Having done all three of these over the years, I would go with the chromebox/cloudprint option. It's far less hassle.

  • Thanks 1
Posted
OK, how would I do the first option ? Namely in Server 2012 R2 ?

 

The printers wont be on the same network as the RDS server.

 

Well, I've probably not done it since 2003 and back then we were using kix!

I'd search windows printer logon scripts; there is loads out there in VBS,PS. You just need something that will pickup the rdp clientname. You can assign it in your AD.

  • Thanks 1
Posted

digging in my powershell scripts folder yields:

 

<#
.SYNOPSIS
   Map printers based on group membership
.DESCRIPTION
   Normally you want to map printers using Group Policies, but if you have a LOT of
   printers you'll find login times will slow significantly, especially if you're using
   Item Level Targeting.  
   
   This script will map printers based on a user's group membership.
   
   To use this script scroll down to the bottom and add Set-MapPrinter statements
   to match your environment.
   
   TROUBLESHOOTING: the script will log successful and unsuccessful printer mappings in
   the SYSTEM Event Log, with a source of "Set-MapPrinter" and include the full error
   message in the log.  
.EXAMPLE
   This example is for the internal Set-MapPrinter function within the script.
   
   Set-MapPrinter -Group "Printer-HP4555" -Share "\\PrinterServer1\HP4555"
   Set-MapPrinter -Group "Accounting" -Share "\\PrinterServer1\HP2025" -default
   
   Maps the printer if the user is a member of "Printer-HP4555", and if you are a 
   member of Accounting it will also map HP2025.  Additionally, HP2025 will be set as
   the default printer.
.NOTES
   Author:            Martin Pugh
   Twitter:           @thesurlyadm1n
   Spiceworks:        Martin9700
   Blog:              [url]www.thesurlyadmin.com[/url]
      
   Changelog:
      2.0             Added ability to support nested groups
      1.11            Non-administrators cannot write to event log, just skip log writing.
      1.1             Add ability to specify default printer
      1.0             Initial Release
.LINK
   [url]http://community.spiceworks.com/scripts/show/2302-map-printers-by-group-membership[/url]
#>
[CmdletBinding()]
Param ()

#Function
Function Set-MapPrinter
{   <#
   .PARAMETER Group
       This parameter is for the internal Set-MapPrinter function within the script.
       
       Name or partial name of the group.  If the user is a member of the group they will
       map the printer that you specify in the Share parameter.
   .PARAMETER Share
       This parameter is for the internal Set-MapPrinter function within the script.
       
       This is the full UNC name of the printer you want to map.  
       
       IE: \\server\printer1
           \\server\printer2
   .PARAMETER Default
       Will cause this printer to be set as the default printer.
   #>
   Param (
       [string]$Share,
       [string]$Group,
       [switch]$Default
   )
   
   Write-Verbose "Mapping $Share if member of $Group"
   If ($Groups -like "*$Group*")
   {   If ($Printers -notcontains $Share)
       {   $Retry = 0
           $ErrorActionPreference = "Stop"
           Do {    
               Try {
                   Write-Verbose "Attempting to connect..."
                   $Network.AddWindowsPrinterConnection($Share)
                   If ($Default)
                   {   $Network.SetDefaultPrinter($Share)
                   }
                   Write-EventLog -LogName System -Source "Set-MapPrinter" -EntryType Information -EventId 1 -Message "Successfully mapped $Share, set to default: $Default" -ErrorAction SilentlyContinue
                   $Retry = 3
               }
               Catch {
                   $Retry ++
                   Write-Verbose "Error mapping printer: $($Error[0])"
                   If ($Retry -eq 3)
                   {   # Show user the error, but Window will only stay open for 8 seconds
                       $Shell.Popup("Unable to map printer: $Share`n`nError: $($Error[0])",8,"Mapping Printer Error",0) | Out-Null
                       # Log the event in the Event Log
                       Write-EventLog -LogName System -Source "Set-MapPrinter" -EntryType Error -EventId 2 -Message $Error[0] -ErrorAction SilentlyContinue
                   }
                   Else
                   {   Write-Verbose "Retrying...`n"
                       Start-Sleep -Seconds 2
                   }
               }
           } Until ($Retry -eq 3)
           $ErrorActionPreference = "Continue"
       }
       Else
       {   Write-Verbose "Printer already mapped: $Share"
       }
   }
   Else
   {   Write-Verbose "Not a member of $Group"
   }
}

Function Get-Groups
{   <#
       .SYNOPSIS
           Recursively get all the Group objects from a group
       .PARAMETER Name
           Name of the group 
   #>
   [CmdletBinding()]
   Param (
       [string[]]$Name
   )
   
   $Return = @()
   ForEach ($Object in $Name)
   {   $objSearcher = New-Object System.DirectoryServices.DirectorySearcher
       $objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry
       $objSearcher.Filter = "(&(objectCategory=Group)(distinguishedName=$Object))"
       $objSearcher.SearchScope = "Subtree"
       $obj = $objSearcher.FindOne()
       If ($obj)
       {   $Return += $obj.Properties["distinguishedName"]
           $Return += Get-Groups $obj.Properties["member"]
       }
   }
   Return $Return
}

#Setup - Get user group memberships and printer names
Write-Verbose "Setting up script..."
$Network = New-Object -ComObject Wscript.Network
$Shell = New-Object -ComObject Wscript.Shell
New-EventLog -LogName System -Source "Set-MapPrinter" -ErrorAction SilentlyContinue

Write-Verbose "Getting $($env:USERNAME)'s groups..."
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher.Filter = "(&(objectCategory=User)(SamAccountname=$env:USERNAME))"
$objSearcher.SearchScope = "Subtree"
$obj = $objSearcher.FindOne()
[string[]]$Groups = $obj.Properties["memberof"]
$Groups += Get-Groups $Groups
$Groups = $Groups | Select -Unique

Write-Verbose "Getting PC's network printers..."
$Printers = Get-WmiObject Win32_Printer -Filter "Network = True" | Select -ExpandProperty Name



########################################
# DO NOT EDIT ABOVE                    #
# EDIT BELOW TO MATCH YOUR ENVIRONMENT #
########################################

Set-MapPrinter -Share "\\PrintServer1\Acct" -Group "Accounting"
Set-MapPrinter -Share "\\PrintServer1\CS" -Group "Customer Service"
Set-MapPrinter -Share "\\PrintServer1\MailRoom" -Group "Domain Users" -Default



########################################
# DO NOT EDIT BELOW HERE               #
########################################
Write-Verbose "Script completed!"

Posted

ok so how would it work then, the PC / local printer will have nothing to do with the RDS Server at all. But local printing is a must through Linux thin client to Remote Desktop session...

 

If I add print drivers into Print Server Properties then add the logon script will this work do you think ?

Posted (edited)
ok so how would it work then, the PC / local printer will have nothing to do with the RDS Server at all. But local printing is a must through Linux thin client to Remote Desktop session...

 

If I add print drivers into Print Server Properties then add the logon script will this work do you think ?

 

That pretty much sums it up. The linux machine is doing nothing except providing access to the local hardware, everything else (including printing) is on the windows server.

 

IF (bold highlight) you want local printing; as in printing from linux apps running on linux, OR the printer is local (not networked) then you need to setup a local linux print server (cups) in addition to this.

Edited by CyberNerd
Posted
OK, how would I do the first option ? Namely in Server 2012 R2 ?

 

The printers wont be on the same network as the RDS server.

 

Coincidentally, I tested printing over a (Microsoft RRAS) L2TP VPN today. It was very easy to setup and works just fine. If your Terminal Server is offsite, you may be best off having it tunnel back to your onsite print server over VPN.

Posted

Mangaged to get it working this way:

 

Linux machine is on fedora, installed printer and used the -r flag on rdekstop and used printername. Printer appeared on the 2012 Remote Desktop Session and printing works fine.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...