Exchange Public Folder - Cannot open mailbox - powershell

We have a Exchange 2013 Version 15.0 (Build 1293.2) running OnPremise in Hybrid with Office365. All our Mailbox are migrated to Exchange online except PublicFolder.
On Preparing the environment to migrate the PublicFolder we accidently deleted them. (Blogpost)
The PublicFolder was only disconnected so we connected it to a new AD-User Blogpost.
But since it was the primary hierachy, the recovered PF was now secondary. I fixed this with ADSIedit and changed the msExchDefaultPublicFolderMailbox. But got no luck access it.
OnPremise with Powershell Get-PublicFolder I get the following:
Cannot open mailbox /o=<DOMAIN>/ou=Exchange Administrative Group
(FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=<SERVER>/cn=Microsoft System Attendant.
+ CategoryInfo : NotSpecified: (:) [Get-PublicFolder], StoragePermanentException
+ FullyQualifiedErrorId : [Server=<SERVER>,RequestId=a0513385-ff9e-472f-a21a-719fbcac071e,TimeStamp=15.11.2017 07:20:42] [FailureCategory=Cmdlet-StoragePermanentException] 4E3BE011,Microsoft.Exchange.Management.MapiTasks.
GetPublicFolder
+ PSComputerName : SERVER.DOMAIN.local
I made a second empty PublicFolder (named test) and changed the msExchDefaultPublicFolderMailbox to set it as primary. Now the Get-PublicFolder worked. But after 5 to 15 minutes the PublicFolder wasn't available again. Another Get-PublicFolder got me the same message as above.
The same thin happened if I changed it back to my reconnected PF (PFU01).
With Get-Mailbox -PublicFolder I can see both PublicFolders:
[PS] C:\Windows\system32>get-Mailbox -PublicFolder
Name Alias ServerName ProhibitSendQuota
---- ----- ---------- -----------------
PFU01 PFU01 <servername> Unlimited
test test <servername> Unlimited
What I checked:
ADSIEdit:
"Microsoft System Attendant" got no value in "homeMDB". (Article)
Change of msExchDefaultPublicFolderMailbox attribute to a new empty PF. (Article)
PowerShell:
test-mapiconnectivity (Result: Success)
Is there any other stuff I can check via ADSIEdit that could be incorrect?
Greetings,
Dominic

Related

How to set Assigned Access for Edge Browser

I would like to set Edge as an Assigned Access to a User.
I'm using the following PowerShell Command:
Set-AssignedAccess -AppUserModelId Microsoft.MicrosoftEdge -UserName xy
But I always get the following error (translated from German):
System error 1376 has occurred.
The specified local group does not exist.
New-CimInstance : A general error has occurred, for which
no specific error code is available.
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\AssignedAccess\AssignedAccess.psm1:300
Zeichen:13
+ New-CimInstance -ClassName WEDL_AssignedAccess -Property ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (WEDL_AssignedAccess:CimInstance) [New-CimInstance], CimException
+ FullyQualifiedErrorId : MI RESULT 1,Microsoft.Management.Infrastructure.CimCmdlets.NewCimInstanceCommand
The local user exists, and the app exists too. I also logged in with the user I want to set the assignedaccess to make sure the profile is set u0p correctly
This happened on two different Windows 10 (build 14393) machines
I'm on PSVersion:
PS C:\WINDOWS\system32> $psversiontable.psversion.toString()
5.1.14393.1944
Does anybody know how to solve this?
Ran in to this yesterday. From what i could tell the "local group" thats referenced is actually the admin group.
I ran the following commands in an elevated powershell prompt:
Net localgroup administrators /add.
This creates a local Administrators group.
Net localgroup administratörer administrators /add.
This adds the administrators group to the local admin group (Administratörer is the Swedish localization of Administrators, use the local version depending on your country and replace it).
After this is done, run your previous commands.
Give it a try, hope it helps :)
//Chris
Set-AssignedAccess -UserName weakusername -AUMID Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge

Powershell Script for adding users to AD

Hi I've just resently started to use powershell on my server. Though when I run the script I get the error:
New-ADUser : Unable to find a default server with Active Directory Web Services running.
At C:\Users\Administrator\Desktop\Powerwhell Script, H1 case.ps1:6 char:1
+ New-ADUser -name $_."fornavn"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [New-ADUser], ADServerDownException
+ FullyQualifiedErrorId : ActiveDirectoryServer:1355,Microsoft.ActiveDirectory.Management.Commands.NewADUser
I have attached the script and my .csv file. Hope any of you can help me figuring it out.
(Don't worry about the information, it's for a school assignment)
Script
.csv file
It looks like your script can not find the domain control on your domain. Simply use the -Server parameter and give it the Full Qualified Domain Name or IP of the domain control.
New-ADUser -Server "ServerName.Domain.com"
If this doesn't work you might not have Active Directory Management Gateway Service installed on your domain control (Download Here). With Windows server 2012 R2 make sure you have the following feature installed.
The headers warning you are seeing is because Import-Csv is unable to get the headings from your CSV file for some reason, and replaces the header name with H1,H2 ... Hx. For example:
fornavn efternavn H1 beskrivelse, ...
------- --------- ----- -----------
Keld Bruun KB Adm.Ledergruppe, ...
You can get round this you can giving Import-Csv the names of your columns via the -Header parameter. Note that these do not have to be the same as the ones in the CSV, as the new column headers will overwrite the CSV.
Import-Csv "C:\H1, Powershell.csv" -Header 'fornavn','efternavn','forkortelse','beskrivelse','email','brugernavn','kode','kontor','fuldnavn'

Get mailbox folder permissions for "remote" mailboxes

I'm using PowerShell commandlets to extract MailboxFolderPermissions.
I'm using Get-MailboxfolderStatistics to get list of folders for particular mailbox and then Get-MailboxfolderPermission to get permissions for all available folders.
All is working fine for mailboxes hosted locally on Exchange server I'm connected to.
But in the same domain there is another Exchange server and mailboxes hosted on it are also listed when invoking Get-Mailbox on the first one.
When I try to run Get-MailboxfolderStatistics or Get-MailboxfolderPermission for such "remote" mailbox I'm getting en error:
For Get-MailboxFolderStatistics cmdlet:
Unable to retrieve mailbox folder statistics for mailbox xxxxxxx#xxxxxx.local. Failure: Error code -2146233088 occurred with message Cannot open mailbox /o=xxxxxxxx/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=EXCH2013/cn=Microsoft System Attendant..
+ CategoryInfo: ReadError: (:) [Get-MailboxFolderStatistics],MailboxFolderStatisticsException
+ FullyQualifiedErrorId : BE037E6,Microsoft.Exchange.Management.Tasks.GetMailboxFolderStatistics
+ PSComputerName: xxxxxxxxxxx
For Get-MailboxFolderPermission cmdlet:
Cannot open mailbox /o=xxxxxxxx/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=EXCH2013/cn=Microsoft System Attendant.
+ CategoryInfo: NotSpecified: (0:Int32) [Get-MailboxFolderPermission], ConnectionFailedTransientException
+ FullyQualifiedErrorId : A44BD817,Microsoft.Exchange.Management.StoreTasks.GetMailboxFolderPermission
+ PSComputerName: xxxxxxxxxxx
Does anyone know what could the cause of above errors?
Is it possible to list permissions for remote mailbox folders?
Any help is really appreciated.
connect remote exchange server via ps session https://technet.microsoft.com/en-us/library/dd335083(v=exchg.160).aspx

Unable to remote to a machine running Powershell 5.0

I've come across a strange error when trying to use Invoke-Command or Enter-PSSession when the destination is running WMF 5.0 (April Preview or August pre-Release).
I haven't been able to find any reference to this on Google so I suspect it's a local/network configuration issue but I'm unsure how to track it down.
The account in question has Local Administrator permissions on both machines (Domain Group is added on both) and I can locally run any and all commands on the destination. Remote access in the opposite direction results in the same error (also running 5.0.10514).
--- Output sanitized of identifiable information and formatting adjusted to wrap better ---
# user#HOST | [2015-09-09 Wed 08:18]
C:\Windows>invoke-command -computer test {$psversiontable.psversion}
Major Minor Build Revision PSComputerName
----- ----- ----- -------- --------------
4 0 -1 -1 test
# user#HOST | [2015-09-09 Wed 08:18]
C:\Windows>enter-pssession -computer test
[test]: PS C:\Users\user\Documents> exit
# user#HOST | [2015-09-09 Wed 08:19]
C:\Windows>invoke-command -computer test {$psversiontable.psversion}
Major Minor Build Revision PSComputerName
----- ----- ----- -------- --------------
5 0 10514 6 test
# user#HOST | [2015-09-09 Wed 08:37]
C:\Windows>enter-pssession -computer test
enter-pssession : The term 'Measure-Object' 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 line:1 char:1
+ enter-pssession -computer test
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Measure-Object:String) [Enter-PSSession],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
# user#HOST | [2015-09-09 Wed 08:38]
C:\Windows>
Are you running your powershell session with elevated privileges (eventhough it's an Administrator accout)?
Is it working if you use a FQDN instead of the simple name? It's a known issue in some of the builds if you're using a simple name for the target.
There might be some restrictions on the commands available, if the endpoint is restricted somehow. The Measure-Object is one of the required methods needed to run in the session when using enter-pssession. This might be your issue; though hard to guess without details of your setup.
Some details on restricting commands and locking down methods in remoting:
https://www.petri.com/powershell-remoting-restricting-user-commands
There are some more details about delegated administration and proxy functions:
http://blogs.technet.com/b/heyscriptingguy/archive/2014/04/03/use-delegated-administration-and-proxy-functions.aspx
If your target is a container, you might need to configure it properly:
https://www.petri.com/managing-windows-server-containers-with-powershell-managing-containers
Hope this helps you debugging and get remoting up working:)
I ran into this problem too. In my case, using the FQDN of the server didn't fix the problem.
Someone posted about a problem caused by the PSModulePath variable.
RDP to the remote server and check the current value of $env:PSModulePath
If the path includes UNCs replace them with the name of a mapped drive (e.g. replace \myserver\public\docs with z:\docs, where z is mapped to \myserver\public)
This worked for me

Start FTP Website from powershell 4

Trying to automate ftp site manipulation on IIS7.5, through powershell, but I can't start the ftp site. Everything else, so far, I succeeded.
PS IIS:\Sites> Get-ChildItem | Where {$_.Name -eq "FtpData"}
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
FtpData 3 Stopped D:\Services\_Empty ftp *:80:
PS IIS:\Sites> Start-WebSite -Name "FtpData"
Start-WebSite : The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8)
At line:1 char:1
+ Start-WebSite -Name "FtpData"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Website], COMException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.IIs.PowerShell.Provider.StartWebsiteCommand
This issue is address in technet "Starting / Stoping an FTP site using PowerShell... IIS 7.5 on 2008R2" but is has three years old.
Using the appcmd has the same issue:
C:\Users\myself>c:\Windows\system32\inetsrv\appcmd start site FtpData
ERROR ( hresult:800710d8, message:Command execution failed.
The object identifier does not represent a valid object.
)
This article FTP on IIS 7 on Server Core indicates to start it from the UI Console, but that means it can't be automated.
Has any one got a solution to this?
Stumbled upon this through Powershell autocomplete and turned out working on Server 2012 R2:
$ftpSite = IIS:\Sites\FtpData
$ftpSite.ftpServer.Start()
The $ftpSite... did not work for me. I also found the below to be neater.
To Start:
(get-Website -Name "myftpsite").ftpserver.start()
To Stop:
(get-Website -Name "myftpsite").ftpserver.stop()
Source: https://peter.hahndorf.eu/blog/iisftp.html
(Forever Breathes The Lonely Word - Peter Hahndorf on software
IIS - Managing FTP sites with PowerShell)