
RvS
Members-
Posts
13 -
Joined
-
Last visited
Everything posted by RvS
-
RunAsWait("admin", "domain", "password", 0, "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Enable-Mailbox -Identity 'domain.domain\" & $Username & "' -Alias '" & $Username & "' -Database 'MAILDB'""", "", @SW_HIDE) ;Creates mailbox for specified user Sleep(6000) RunAsWait("admin", "domain", "password", 0, "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-Mailbox -Identity 'domain.domain\" & $Username & "' -EmailAddressPolicyEnabled:$True""", "", @SW_HIDE) ;Enables mail policy The first line makes the mailbox for an existing user, the second line is a fix to a weird bug. Our policy adds an x400 and some aliases. By default, the box that applies the policies is ticked in the mailbox properties, but it doesn't actually apply them. Only if I untick/tick it by hand and Apply from the Console or run that second line it will actually apply the policy and add the aliases/x400. Not a big hassle. The Sleep() is required, it needs a moment to create the mailbox. Without the Sleep() the 2nd script will tell me the user doesn't exist.
-
Calling the Exchange shell from cmd works perfectly. C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Enable-Mailbox -Identity 'domain.domain\rvstest' -Database 'DB01'" Slap @SW_HIDE on it and it won't even be visible.
-
Quick question. I'm using PowerGUI for script writing, which allows me to enable PowerShell modules (I ticked on AD + Exchange modules) My code then works, from PowerGUI. From normal PowerShell started in Win7, it will not. It spits out The term 'Enable-Mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At \\share\createmail.ps1:1 char:15 + Enable-Mailbox <<<< -Identity 'domain.domain\rvstest' -Database 'DB01' + CategoryInfo : ObjectNotFound: (Enable-Mailbox:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException when I fire Enable-Mailbox -Identity 'domain.domain\rtesting' -Database 'EXDB01' into the command line. I reproduced this behaviour in the scripting program when I ticked off AD+Exchange modules. Halp. It needs to run under normal PowerShell.
-
K, now I got it. Enable-Mailbox -Identity 'domain.domain\rvstest' -Database 'DB01' Works for existing users.
-
This: New-Mailbox -Name $Name -Alias $Alias -OrganizationalUnit 'domain.domain/Users' -UserPrincipalName $UPN -SamAccountName $SAM -FirstName $FirstName -Initials '' -LastName $LastName -Password $Password -ResetPasswordOnNextLogon $true -Database 'DBNAME' Has worked like a charm for me. EDIT: Doesn't work if user already exists. Finding workaround...
-
Yeah I was leaning towards PowerShell as well. I'll see what I can setup. All mine has to do is create a User Mailbox.
-
Brilliant. Works like a charm. Small question; CreateMailbox script does not work anymore for post-2007 servers? Running Exchange 2010 Server. It'd be really great if my tool could automate both user account, profile folders AND mailboxes.
-
Hi water, the CreateUser function nor your property suggestion seems to do the trick. The box stating the user must change their password @ next login remains unchecked... $var = _AD_ModifyAttribute($Username, "pwdLastSet", "-1") and $var = _AD_ModifyAttribute($Username, "pwdLastSet", -1) both don't check the box.
-
Another quick question; I'm using this: http://www.kouti.com/tables/userattributes.htm As a reference for filling out the right fields/checks. I'm missing something though. When a user is created, they need to change their password upon first login, how do I tick this box with AutoIt?
-
Got it. You my day. I was thinking for some reason that HomeDrive = Network and Homedir = Local ;Homedir change Global $2 = _AD_ModifyAttribute($Username, "homeDrive", "P:") Global $3 = _AD_ModifyAttribute($Username, "homeDirectory", "\\server\homedir$\" & $Username)
-
Dear water, I'm currently writing some scripts to automate making a new user for our help/support desk. The script makes the user correctly and assigns homedrives/profile folders I tell it to. Now there's a problem; _AD_ModifyAttribute($Username, "homeDir", "\\server\homedrive$\" & $Username) This works. But then there is no Drive Letter assigned (blank space in the AD) and Windows ignores the drive completely. I cannot seem to find the function to add a drive letter to the home drive. Thanks in advance!
-
The edit: helped me fix the output problem, but Im not sure how to replace Line 4. I have to keep the rest intact: quality 1 screen 1 shadow 1 resolution 800 600 username roger lastname doe I need to keep the rest the same, and only change "800 600" and replace it with whatever I put as variable $GUI_CBOX_WIDTH EDIT: This ini file wont work with: [section] value=1 The structure of lines has to be preserved and it can only make: value 1
-
Hi, I'm currently trying to create a little GUI for editing a .ini file. What it needs to do is replace the "resolution 800 600" on Line 4 with "resolution $variable" When I use $file = FileOpen("file.ini", 2) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($file, "Line1") FileWriteLine($file, "Line2") FileWriteLine($file, "resolution " & $GUI_CBOX_WIDTH) FileClose($file) I used this scrap (which doesnt do what I want but I can write the entire line by myself too, I dont care) It will write me lines, but it will replace the variable with "6" or "1" where I pick 800 600 from the Combobox. Here's the combobox and variables: Global $GUI_CBOX_WIDTH = GUICtrlCreateCombo("Pick a width (pixels)", 112, 240, 121, 25) GUICtrlSetData(-1, $RESOLUTIONS, "") $RESOLUTIONS = "800|1024|1280" Help please =[