I’m new to PS and using PS v7. When I execute Get-Group, Get-DistributionGroup, etc, I get a failure from ConvertFrom-Json that indicates that somewhere in the called cmdlet that JSON was expected, but not actually encountered. Does this indicate that I haven’t appropriately configured the PS environment for these cmdlets? Ex from Get-Group: ConvertFrom-Json: Conversion from JSON failed with error: Unexpected character encountered while parsing value: U. Path ‘’, line 0, position 0.
twtuck,
Welcome to the forum.
Since we cannot see your screen or cannot read your mind you have to help us helping you. Please share the code you used and the complete error message you get - bot formatted as code please.
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance
How to format code in PowerShell.org 1 <---- Click
Get-Group
ConvertFrom-Json: Conversion from JSON failed with error: Unexpected character encountered while parsing value: U. Path ‘’, line 0, position 0.
You haven’t explained nearly enough. Is this exchange online? If so, what version of the exchangeonlinemanagement module are you using? It sounds like you may have a custom Get-Group function, because no where in the cmdlet Get-Group should there be any json conversion. Here is the definition of Get-Group
Get-Command Get-Group | Foreach-Object Definition
[CmdletBinding(DefaultParameterSetName='Identity')]
param(
[Parameter(ParameterSetName='AnrSet')]
[ValidateLength(3, 5120)]
[string]
${Anr},
[ValidateNotNullOrEmpty()]
[string]
${Filter},
[Parameter(ParameterSetName='Identity', Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
${Identity},
${OrganizationalUnit},
[ValidateNotNullOrEmpty()]
[System.Object[]]
${RecipientTypeDetails},
${ResultSize},
[string]
${SortBy}
)
Begin {
$CmdletRequestId = [System.Guid]::NewGuid().ToString()
$cmdletRequestIdGeneratedInBegin = $true
# Initalize the cmdletactivity.
$cmdletIDList = [System.Collections.ArrayList]::new()
$null = $cmdletIDList.Add($CmdletRequestId)
$startTime = Get-Date
Init-Log -CmdletId $CmdletRequestId
Log-Column -ColumnName StartTime -CmdletId $CmdletRequestId -Value $startTime
Log-Column -ColumnName CmdletName -CmdletId $CmdletRequestId -Value $MyInvocation.MyCommand.Name
Log-Column -ColumnName CmdletParameters -CmdletId $CmdletRequestId -Value $MyInvocation.BoundParameters
try
{
$UseBatching = $false;
# Use batching only if pipelined cmdleted being executed
if ($PSCmdlet.MyInvocation.ExpectingInput)
{
$UseBatching = $true;
}
$BatchBodyObj = @{};
$BatchBodyObj['requests'] = New-Object System.Collections.ArrayList;
$BatchRequestParameters = New-Object System.Collections.ArrayList;
}
catch
{
$endTime = Get-Date
Log-Column -ColumnName GenericError -CmdletId $CmdletRequestId -Value $_
Log-Column -ColumnName EndTime -CmdletId $CmdletRequestId -Value $endTime
Commit-Log -CmdletId $CmdletRequestId
throw $_
}
}
Process {
# If cmdletRequestIdGeneratedInBegin is false then this is a pipeline call. Initialize a new cmdletRequestId only if we are not batching requests together, or we are starting a new batch.
# Set cmdletRequestIdGeneratedInBegin back to false before the next cmdlet is called.
$cmdletRequestIdGeneratedInProcess = $true
if ($cmdletRequestIdGeneratedInBegin -eq $false -and ((-not $UseBatching) -or ($UseBatching -eq $true -and $BatchBodyObj -ne $null -and $BatchBodyObj['requests'].Count -eq 0)))
{
# Initalize the cmdletactivity, this is pipeline request without batching, or it is the first request in a batch
$CmdletRequestId = [System.Guid]::NewGuid().ToString()
$cmdletRequestIdGeneratedInProcess = $true
Init-Log -CmdletId $CmdletRequestId;
$startTime = Get-Date
Log-Column -ColumnName StartTime -CmdletId $CmdletRequestId -Value $startTime
$null = $cmdletIDList.Add($CmdletRequestId);
}
$cmdletRequestIdGeneratedInBegin = $false
Log-Column -ColumnName CmdletName -CmdletId $CmdletRequestId -Value $MyInvocation.MyCommand.Name
Log-Column -ColumnName CmdletParameters -CmdletId $CmdletRequestId -Value $MyInvocation.BoundParameters
try
{
Execute-Command -CmdletName 'Get-Group' -Parameters $PSBoundParameters -CmdletRequestId $CmdletRequestId
}
catch
{
$endTime = Get-Date
Log-Column -ColumnName GenericError -CmdletId $CmdletRequestId -Value $_
Log-Column -ColumnName EndTime -CmdletId $CmdletRequestId -Value $endTime
Commit-Log -CmdletId $CmdletRequestId
throw $_
}
finally
{
# For pipeline cases, EndProcessing is not called for each cmdlet in the pipeline, so we will log the end time here.
# When batching is enabled, and the batch request is executed in this ProcessRecord, the log will be committed either inside Execute-Command or in the end block.
if (-not $UseBatching)
{
$endTime = Get-Date;
Log-Column -ColumnName EndTime -CmdletId $CmdletRequestId -Value $endTime
}
}
}
End {
try
{
if($BatchBodyObj['requests'].Count -gt 0)
{
$BatchResponse = Execute-BatchRequest -CmdletRequestId $CmdletRequestId
Deserialize-BatchRequest -BatchResponse $BatchResponse -CmdletRequestId $CmdletRequestId
# Resetting the batched requests as they are already handled
$BatchBodyObj['requests'] = New-Object System.Collections.ArrayList;
$BatchRequestParameters = New-Object System.Collections.ArrayList;
}
}
catch
{
$endTime = Get-Date
Log-Column -ColumnName GenericError -CmdletId $CmdletRequestId -Value $_
Log-Column -ColumnName EndTime -CmdletId $CmdletRequestId -Value $endTime
Commit-Log -CmdletId $CmdletRequestId
throw $_
}
$endTime = Get-Date;
Log-Column -ColumnName EndTime -CmdletId $CmdletRequestId -Value $endTime
foreach ($id in $cmdletIDList)
{
Commit-Log -CmdletId $id
}
}
from ExchangeOnlineManagement version 3.0.0.0
Get-Module ExchangeOnlineManagement
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 3.0.0 ExchangeOnlineManagement {Get-ConnectionInformation, Get-EXOCasMailbox, Get-EXOMail.
Thank you greatly for trying to help me.
I’m using the Get- cmdlets found in ExchangeOnlineManagement v3.0.0 from Gallery. It isn’t custom.
I shared the same question, and why I mentioned a configuration problem with my PS v.7 install. It was a fresh install followed by Install-Module AzureAD -Scope AllUsers, Install-Module ExchangeOnlineManagement -Scope AllUsers. Maybe I should revisit my installation procedure?
This might be a result of WinRM misconfig OR a 3rd-party network filter used by my company. I’ll investigate.
Will ask the standard first question you would get from Microsoft… have you tried updating to latest version of PS 7.x and ExchOnline PS modules 3.x ? I ask because the version you list are old.
Do you have a way to eliminate your company network? never underestimate proxy and firewalls to make your life miserable with Azure/M365 if they are not configured correctly. If you can, that would help narrow down where to put your efforts. If on network no work, but off it does, that points to something network related. If you can then eliminate your workstation, that puts the focus on routers and proxy devices.
No I really suspect you have a custom function, it’s really the only thing that makes sense. Or maybe you have some customization modules/profile settings that are the culprit. Get-Group does not do any json conversion, that’s coming from somewhere else. Run this and share the output please.
Get-Command Get-Group
Also, try opening powershell with no profile and try again, see if that makes any difference.
pwhs.exe -noprofile