get-remotemailbox not working in script

Home Forums Messaging Software Exchange 2007 / 2010 / 2013 get-remotemailbox not working in script

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #617564

    Hello,
    I’m fairly new to Powershell and trying to process a list of users to report, change and set customattributes. Currently just trying to ready the current value and it’s not working.
    The following script keeps keeps given the wrong variable when I output to screen.
    here’s the Output:
    [PS] C:\scripts\Exchange-Tools>.\ExAttribute-Editor.ps1
    Enter name of the .csv file in C:\Scripts\Exchange-Tools?: 625-ADD.csv
    Enter the value number for the Attribute?: 5
    Enter the Custom Attribute Number or Name?:
    @{-CustomAttribute5=} Result output!!!
    Attribute value for List is: LOUIS BAXTER
    Value for CustomAttrib2 is: -CustomAttribute5
    Result @{-CustomAttribute5=} is currently set for user: LOUIS BAXTER

    Script:
    import-module activedirectory
    $File01 = “C:\Scripts\Exchange-Tools”
    $File02 = (Read-Host “Enter name of the .csv file in C:\Scripts\Exchange-Tools?”)
    $AttribValue = (Read-Host “Enter the value number for the Attribute?”)
    $CustomAttrib = (Read-Host “Enter the Custom Attribute Number or Name?”)
    $CustomAttrib2 = “-CustomAttribute” + $AttribValue.Trim()
    $Path = “$file01\$File02″
    $csv = Get-Content $Path
    foreach($item in $csv)
    {
    $List = $item
    $OutFile = Get-RemoteMailbox -Identity:”$List” |Select $CustomAttrib2
    $out2 = $OutFile
    Write-host $out2 “Result output!!!”
    #$Result = Get-RemoteMailbox “$List” |Select-Object $CustomAttrib2
    #(get-mailbox “$List”).$CustomAttrib2
    Write-Host “Attribute value for List is: ” $List
    Write-Host “Value for CustomAttrib2 is: ” $CustomAttrib2
    #Write-Host “Attribute value for Result is: ” $Result
    #Start-Sleep -s 4
    Write-Output “Result $OutFile is currently set for user: $List”

    Any help you can provide as to why the $OutFile variable is not working is much appreciated!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.