Solved

PowerShell Script to modify session attributes in user objects

Posted on 2014-10-22
12
252 Views
Last Modified: 2014-10-22
I have a script I have written to modify the '-TsMaxDisconnectionTime' to 15 minutes against a list of users in a csv file. the script runs without any incidents or errors. At the end of my time line and no longer have the time to research... any help would be greatly appreciated...

Import-Module ActiveDirectory

Add-PSSnapin Quest.ActiveRoles.ADManagement

$users = import-csv C:\temp\gisuserscfw.csv | ForEach-Object {Get-QADUser -SamAccountName $_.SamAccountName}
{
Set-QADUser -Identity $User -TsMaxDisconnectionTime "00:15"
}
0
Comment
Question by:TXRhino
  • 7
  • 5
12 Comments
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40397002
So what is the question? You said it runs with no errors?
0
 

Author Comment

by:TXRhino
ID: 40397020
Sorry... it runs with no errors but dosent make the change... when I run it per user it correctly changes the attribute to 15 minutes... it has something to do with the way I am calling the csv file...
0
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40397023
This will work. You just have to make sure your CSV file has a Column Header named SamAccountName

Import-Module ActiveDirectory
Add-PSSnapin Quest.ActiveRoles.ADManagement
$Users = Import-Csv C:\temp\gisuserscfw.csv | ForEach-Object { Set-QADUser -Identity $_.SamAccountName -TsMaxDisconnectionTime '00:15:00' } 

Open in new window

0
 

Author Comment

by:TXRhino
ID: 40397051
I do have the header named 'SamAccountName' here is the error it returns... I also insured that I do have the actual username aka SamAccountName in the csv file.


Set-QADUser : Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))
At line:3 char:64
+ $Users = Import-Csv C:\temp\gisuserscfw.csv | ForEach-Object { Set-QADUser -Iden ...
+                                                                ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-QADUser], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.SetUserCmdlet
0
 

Author Comment

by:TXRhino
ID: 40397054
0
 
LVL 16

Accepted Solution

by:
Joshua Grantom earned 500 total points
ID: 40397175
Give this a shot. I would make sure that your csv file is a true CSV. Open with Notepad and make sure it is comma separated and not tab separated or any other

Import-Module ActiveDirectory
Add-PSSnapin Quest.ActiveRoles.ADManagement
Import-Csv C:\users.csv | % {
$user = $_.SamAccountName
Set-QADUser $user -TsMaxDisconnectionTime "00:15"}

Open in new window

0
Do email signature updates give you a headache?

Do you feel like all of your time is spent managing email signatures? Too busy to visit every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

 

Author Comment

by:TXRhino
ID: 40397371
Same result... I even created a new export of the list to ensure the comma separated value was correct. I ran the code against both and both I get the same result...

Set-QADUser : Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))
At line:5 char:1
+ Set-QADUser $user -TsMaxDisconnectionTime "00:15"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-QADUser], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.SetUserCmdlet

I wonder if I should save it as a script and run in it with in the ISE?
0
 

Author Comment

by:TXRhino
ID: 40397381
that did it... I wonder why running as a script was successful but not from with in ISE?
0
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40397385
The script you are trying to run uses Quest commandlets, do you have those installed on your PC?
0
 

Author Closing Comment

by:TXRhino
ID: 40397388
thanks for the assistance... let me know your thoughts on running as a script vs. ISE thanks again...
0
 

Author Comment

by:TXRhino
ID: 40397391
yes... I even included the command in the script to load them into the session  Add-PSSnapin Quest.ActiveRoles.ADManagement
0
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40397393
hmm, that's interesting.
0

Featured Post

How does your email signature look on mobiles?

Do your employees use mobile devices to reply to emails? With mobile becoming increasingly important to the business world, it is in your best interest to make sure that your email signature looks great across all types of devices.

Join & Write a Comment

My GPO's made for 2008 R2 servers were not allowing me to RDP into a new 2012 server by default.  That’s why I tried to allow RDP via Powershell, because I could log into a remote shell without further configuration. Below I will describe how I wen…
The reason that corporations and businesses use Windows servers is because it supports custom modifications to adapt to the business and what it needs. Most individual users won’t need such powerful options. Here I’ll explain how you can enable Wind…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now