Unable to run ps1 script on cluster
Hi all, I'm trying to import a csv file with the following format alias,first,last jbloggs,Joe,Bloggs and the following ps script Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin #Gets the Server Name $server = [System.Environment]::MachineName #Domain Name $domain = "test.local" import-csv "c:\UserAccounts.csv" | foreach{ #Create the ID $id = $("$domain"+"\"+$_.Account); $alias = $_.Account #Get the first character of the Last name $str =$_.Last.substring(0,1) $Database="" #Set the Database based on the first character of the Last name #You might need to change the name of the Storage Group and Database based on #your environment. switch -regex ($str.ToLower()) { "[a-g]" {$Database = $server+"\SG02\"+"A-G"} "[h-m]" {$Database = $server+"\SG03\"+"H-M"} "[n-z]" {$Database = $server+"\SG04\"+"N-Z"} default {$Database = $server+"\First Storage Group\"+"Mailbox Database"} } # Run the actual command to enable the mailbox. enable-Mailbox -Identity $id -Database $Database -Alias $alias -DisplayName $($_.First+ " " + $_.Last) } and the following error is generated. Import-Csv : Cannot open file C:\UserAccounts.csv. At C:\scripts\enable2.ps1:8 char:11 + import-csv <<<< "c:\UserAccounts.csv" | The only different is that I'm running this on a cluster and it does not matter which node i'm running it on. But when i run the same script on a stand-alone e2k7 it does not have a problem. Would this be a cluster issue? Thanks in advance.
October 13th, 2008 2:14am

Hi Michael, It says "Import-Csv : Cannot open file C:\UserAccounts.csv.", are you able to open fine with below command in powershell from the cluster node locally? Make sure that path and file are exist and porperly formatted. Import-Csv c:\UserAccounts.csv Reference: Using the Import-Csv Cmdlet http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/import-csv.mspx
Free Windows Admin Tool Kit Click here and download it now
October 13th, 2008 1:24pm

Hi Amit, I'm able to run the import-csv without a problem. I've been running it on the local nodes and both come up with the same problem. Strange?
October 14th, 2008 2:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics