anyone have any idea what I may need to change. I have the code below that works fine. But recently I've decided to hide the mailbox from the address book. This has cause the below script to stop working.. If I unhide the mailbox it works again. But I would prefer to keep it hidden.
quick description of what it does. it gets a shared mailbox then a specific folder in the inbox folder and then gets all the emails in that folder.
$Outlook = New-Object -comobject Outlook.Application
$namespace = $Outlook.GetNameSpace("MAPI")
$olRecipient = $namespace.CreateRecipient("sharedmailbox@mail.com")
$SInbox = $namespace.GetSharedDefaultFolder($olRecipient,"6")
$targetFolder = $SInbox.Folders('targetfolder')
$Completedfolder = $targetFolder.Folders("Complete")
$Emails = @()
$Emails = $targetfolder.Items