Solved

PowerShell Script to modify session attributes in user objects

Posted on 2014-10-22
12
259 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was assigned the task of performing a hardware refresh in the datacenter. The previous Windows 2008 systems were connected to the SAN via fiber channel HBA’s and among other thing, had PowerPath installed in order to provide sufficient f…
This article will review the basic installation and configuration for Windows Software Update Services (WSUS) in a Windows 2012 R2 environment.  WSUS is a Microsoft tool that allows administrators to manage and control updates to be approved and ins…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

929 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

11 Experts available now in Live!

Get 1:1 Help Now