PowerShell, Office365: Set-Mailbox parameters raises error - powershell

I am using PowerShell for managing my Office365 account. When I try to set parameters for existing mailbox, PowerShell ISE raises error. When I specify "RetentionComment", "LitigationHoldEnabled", "RetentionUrl" or "MaxSendSize" as Set-Mailbox function the following error occurs:
A positional parameter cannot be found that accepts argument '-maxsendsize'.
+ CategoryInfo : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Set-Mailbox`
These parameters documented in TechNet documentation library at
http://technet.microsoft.com/en-en/library/bb123981(v=exchg.150).aspx
For example I use the following commands with parameters:
Set-Mailbox -Identity "my.mailbox" -MaxSendSize 12345
Set-Mailbox "my.mailbox" -RetentionComment "Hello World!"
Set-Mailbox -Identity "my.mailbox" -LitigationHoldEnabled:$False
Any idea? Please help!

The MaxSendSize is only supported in Exchange 2013 or Exchange Online 2013. If your tenant has not been upgraded yet to wave 15 (the 2013 suite) you will not be able to use this command. Also, if you have ADFS set up you may also be unable to run this command because it must be set in AD and not in Exchange. Hope this helps.

For the -MaxSendSize 12345BI think you have to add a unit to the end so -MaxSendSize 12345B the available units are B/MB/GB/TB.
For -RetentionComment this comment can only be set if the RetentionHoldEnabled parameter is set to $true. So check that first.
For -LitigationHoldEnabled you don't need that : in there so -LitigationHoldEnabled $false

Related

InvalidCastException when trying to obtain UserPrincipal.Current

I have a PowerShell script which checks the currently signed in user as part of its start-up process. I'm using .Net to do this by adding the assembly:
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$cUser = [System.DirectoryServices.AccountManagement.UserPrincipal]::Current
For almost everyone this works fine and I get a UserPrincipal object that I can use elsewhere, however there are a couple of users who get the following error when running it:
Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'. At line:2 char:1
+ [System.DirectoryServices.AccountManagement.UserPrincipal]::Current
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], InvalidCastException
+ FullyQualifiedErrorId : System.InvalidCastException
This is on a standard Windows 10 20H2 install and doesn't matter if PowerShell is running elevated or not. I've never seen this call return anything other than a UserPrincipal before, so I would be grateful for any advice: is this something I can deal with in code, or is there some underlying issue with the machines that are returning this exception?
I don't know if this is what you're looking for:
$cUser = Get-ADUser $Env:Username -Properties *
This has the most important attributes that you can use for whatever you want later on. It provides as much attribute as the code you posted that didn't work for some of the user.

Invoking command at dc - get gpinheritance - wont work

I am writing a script where a part of it needs to connect to domain controller and get all the gpo's currently linked to a specific OU.
the line that does that is:
Invoke-Command -Session $S -ScriptBlock {Get-GPInheritance -target $using:Switch -domain shahar.local -server dc01 }
$s= credentials, $switch is a a variable that contains an ou that was picked.
those variables exists and they are good.
the error i get is:
Value does not fall within the expected range.
+ CategoryInfo : NotSpecified: (:) [Get-GPInheritance], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.GroupPolicy.Commands.GetGPInheritanceCommand
+ PSComputerName : DC01
can anyone please assist?
I'm posting this as answer, because IMO there are too many questions that remain 'unanswered' while the solution is given in a comment.
The error message triggered me to check if any of the variables you use perhaps is an Automatic variable and in this case it is the variable $switch.
Using a different self-defined variable name here like $selectedOU should solve the problem.

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 Exchange CU11 Pipe |

I have 4 Exchange 2013 servers on 2012R2.
3 servers are updated to CU11, last one is running CU10.
After the update to CU11 there are some piped commands I can't run on the servers that are updated to CU11, like this one:
Get-TransportService | Get-MessageTrackingLog -Recipients mail#mail.com
The error I get is this:
The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
+ CategoryInfo : InvalidArgument: (Exchangerservername:PSObject) [Get-MessageTrackingLog], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Get-MessageTrackingLog
+ PSComputerName : xxxxxx
I have tried to write the command not copy.
Also tried to Set-ExecutionPolicy Unrestricted.
Powershell version is the same on all servers.
Easiest way around this is to use a foreach:
get-transportservice | foreach {get-messagetrackinglog -resultsize unlimited `
-start 05/21/2016 -recipient user#email.com}
I don't know if this is your issue but there are known Exchange Management Shell issues with CU11. https://jaapwesselius.com/2016/01/19/exchange-2013-cumulative-update-11-install-it-or-not/ Here is a link.

Set-SPBusinessDataCatalogThrottleConfig : Cannot bind parameter 'Identity'

If you are working with a larger external list (more than 2000 items) in dev environment it works perfectly, but when you work in production environment, it throws error
"Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator. Correlation ID: ...........".
So start to working to fix the BCS limit through powershell.
When I enter below command in powershell I get error in cmd. Any idea?
PS C:\Program Files\Nintex\Nintex Workflow 2010> Set-SPBusinessDataCatalogThrott
leConfig -Identity Get-SPBusinessDataCatalogThrottleConfig -Scope ThrottleType I
tems Database-GUID-ServiceApplicationProxy 5222b2db-fdd1-43f5-accb-7f039155f654-
8000-default maximum 6000
Set-SPBusinessDataCatalogThrottleConfig : Cannot bind parameter 'Identity'. Can
not convert the "Get-SPBusinessDataCatalogThrottleConfig" value of type "System
.String" to type "Microsoft.SharePoint.BusinessData.SharedService.ThrottleConfi
g".
At line:1 char:50
+ Set-SPBusinessDataCatalogThrottleConfig -Identity <<<< Get-SPBusinessDataCat
alogThrottleConfig -Scope ThrottleType Items Database-GUID-ServiceApplicationPr
oxy 5222b2db-fdd1-43f5-accb-7f039155f654-8000-default maximum 6000
+ CategoryInfo : InvalidArgument: (:) [Set-SPBusinessDataCatalogT
hrottleConfig], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.SharePo
int.BusinessData.SharedService.SPSetSPBusinessDataCatalogThrottleConfig
At first glance there seems to be some issues in your PowerShell syntax. You specify another cmdlet as value for the -Identity parameter, and that won't work. Sharepoint is not really my expertise, but this article by lionelro on the msdn blogs looks like a good place to start. Especially since the start of the article describes your issue online appearing on the production environment. Hope it helps.