Welcome to Port3101.org : Your BES Connection Mark forums read | View Forum Leaders
Port3101.org : Your BES Connection



Reply
LinkBack Thread Tools Display Modes
PS Script for BES Account Status
 
  #1 (permalink)  
Old 03-17-2014, 03:03 PM
BES Activated
 
Join Date: May 2010
Location: Milwaukee, WI
Posts: 2
Default PS Script for BES Account Status

Hi all,
I'm trying to build a PowerShell script that will query the BESMgmt database for a particular user's email address (MailboxSMTPAddr in UserConfig?). Depending on whether a BES account exists for that user determines how we proceed. I'm thinking it best to "SELECT * FROM UserConfig", store the info, then search for the email address.

I am able to connect to the database no problem. The part I'm hung-up on is how to "offload" the data from the database into a table or dataset, then search that for the particular email address.

If there's better logic to determining BES account existence given an email address, I'd appreciate that too, but it must be in PowerShell.

Thanks!
Gawl
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-17-2014, 03:23 PM
hdawg's Avatar
Proprietor
 
Join Date: Nov 2008
Posts: 2,257
Blog Entries: 147
Default

why not just modify your query to be:

select * from userconfig where mailboxsmtpaddr = "XXXXX"

where XXXXX is the email address in question.

perhaps i just need an explanation of what your end goal is here.
__________________
http://blog.port3101.org/hdawg/
Reply With Quote
  #3 (permalink)  
Old 03-17-2014, 11:22 PM
BES Activated
 
Join Date: May 2010
Location: Milwaukee, WI
Posts: 2
Default

Using 'where' definitely narrows it down, but I need to do something like the below, with $UserSMTP as the user's email address from ActiveDirectory ($UserSMTP=Get-Mailbox $UserID | select PrimarySMTPAddress).

All I need is to know is if the value is found, and how to then pass the result back to PowerShell. I don't know anything about passing PowerShell variables to a SQL query.

$SqlCmd.CommandText = "SELECT * from UserConfig where MailboxSMTPaddr = $UserSMTP"
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$BESListvalue=$DataSet.Tables[0] | format-list
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Script to read BBUser Status bbusr Scripts & Tools / Hints & Tricks 3 12-16-2013 12:40 PM
mass account creation script #james Scripts & Tools / Hints & Tricks 0 08-31-2011 11:52 AM
Software Config Status devans Port 3101: The BES Admin Bar & Grill 2 06-18-2009 11:23 AM
BES and BIS account on the same device RickyTR Power Users 2 02-11-2009 06:08 AM


All times are GMT -4. The time now is 01:57 AM.
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.


 

SEO by vBSEO 3.3.2 PL2