Our organisation is moving to chrome as the default browser.
The problem is, its already on most of the fleet and custom language settings are set to en-US. I need some way to modify it to be en-AU.
I initially used fart.exe and replaced all instances of en-US with en-AU but when chrome re-launched it didnt like the format.
What i am basically trying to do is replace:
"intl":{"accept_languages":"en-US,en-AU,en-GB,en","selected_languages":"en-US,en-AU,en-GB,en"}
with
"intl":{"accept_languages":"en-AU","selected_languages":"en-AU"}
The problem is the text after "accept_languages": could be any combination of country locale settings.
I'm stumped. Could anyone point me in the right direction?
There is no need for regex in this case, you can use ConvertFrom-Json to update it:
$json = #'
{
"intl":{
"accept_languages":"en-US,en-AU,en-GB,en",
"selected_languages":"en-US,en-AU,en-GB,en"
}
}
'# | ConvertFrom-Json
$json.intl.'accept_languages' = 'en-AU'
$json.intl.'selected_languages' = 'en-AU'
$json | ConvertTo-Json | Out-File path\to\json.json -Encondig utf8
In the example above, $json | ConvertTo-Json would yield a Json like this one:
{
"intl": {
"accept_languages": "en-AU",
"selected_languages": "en-AU"
}
}
Note, the default encoding of the file seems to be ANSI, in this case -Encondig Default should work. Thanks #Theo.
Related
I'm pretty stuck and can't find anything about it on the internet. I'm also not sure how to describe the thing i'm looking for, so maybe someone can help me.
I've got some code to create a ticket in TopDesk through API using invoke-restmethod in PS.
For the request field in TopDesk, I need some output stored in a variable, but if I want to use a variable in the PS command, I need to define the JSON body with the use of #{} | covertTo-JSON (found that somewhere on the internet).
Now this parameter I need to put through, has to have a definition. I need to give in in the value is a email or a name.
$json = #{
"callerLookup" = "{ email : email#domain.com }"
} | Convertto-JSON
Now the thing is, TopDesk doesn't see the "{ email : email#domain.com }" as a correct value.
Before, I just the following (which will work, but can't use variables):
$body = '{"email": "automation#rid-utrecht.nl"}'
I hope I described my problem cleary enough and hope that someone can help me.
Thanks in advance.
Kind regards,
Damian
For ConvertTo-Json to produce the serialized { "property" : "value" } syntax, you must pass it an object that has a property called property and an associated value equal to value. You can easily create this scenario with the [pscustomobject] accelerator.
$json = #{
callerLookup = [pscustomobject]#{email = 'email#domain.com'}
} | ConvertTo-Json
I run the Get-CsCallQueue | Select-Object -Property Name,Agents cmdlet, but I want to see the real names of the agents. Instead I get something like hashes(?).
How can I see the names?
Get-CsCallQueue | Select-Object -Property Name,Agents
Name Agents
---- ------
CQ1 {adfe5681-ebc8-xxx-xxxx-........, OptIn}
CQ2 {adfe5681-ebc8-xxx-xxxx-......., OptIn}
CQ3 {baae77b8-5ace-xxx-xxxx-......, OptOut}
Is this Skype for Business Online (SFBO) or on-prem? You need to match up the agent GUID with the agent name. You'll need to use different cmdlets depending on your answer. Here's an example of how to do this using SFBO:
$queue = get-cscallqueue -NameFilter "<queue name here>"
$agents = $queue.agents
foreach ($agent in $agents) {
$user = $agent.ObjectId | Get-CsOnlineUser
$agent | Add-Member -NotePropertyName Name -NotePropertyValue $user.alias
}
$agents|Select Name,OptIn
Thanks,
Jason
Working on this with a Script that does the heavy lifting for you.
Module is Teamsfunctions on PSgallery.
The command is Get-TeamsCallQueue. I have surfaced all friendly names for Get/New/Set/Remove for CallQueues (I still need to finish testing on them, so handle with care :), should be finished in the coming weeks)
There is also Find-AzureAdUser in my module so that you can get the Object by feeding it the UPN instead of the ObjectID.
Hope that helps :)
I'm trying to list all my Azure VMs with their sizes using a powershell command.
Problem is that the HardwareProfile property returns a JSON object, that I would like to parse and use only the vmSize property value of that object.
So I'm running this command:
Get-AzureRmVM
Which gives me this:
ResourceGroupName : TESTRG
...
Name : ubuntu-server
...
HardwareProfile : {
"vmSize": "Standard_DS2"
}
...
NOTE the JSON in the HarwareProfile value.
What I want to do is:
Get-AzureRmVM | Select ResourceGroupName, Name, HardwareProfileText `
| Out-Gridview -PassThru
Which works - only, I would like to get rid of the JSON notation in the HardwareProfileText. Using Format-Table looks like so:
ResourceGroupName Name HardwareProfileText
----------------- ---- -------------------
TESTRG ubuntu-server {...
So the question is: how can I get only the value of vmSize in this table ? Can I sneak ConvertFrom-Json in somewhere?
Can't you use the select-expression directly and convert the json-string into an object? So you can use it later in your pipeline.
Something like :
select #{Name="VMSize";Expression={($_|ConvertFrom-Json).vmSize}};
Given your json as a text in a file (for a simple-test):
(Get-Content -raw C:\tmp\test.json)|select #{Name="VMSize";Expression={($_|ConvertFrom-Json).vmSize}};
This will give you a property with only the VmSize. You can combine the expression select with normal properties as well, or multiple expressions and then continue to pass it down the pipeline if you want to filter on additional criteria.
I don't know the get-azureRmVm function but it works just fine with the property InstanceSize instead of HardwareProfileText.
Import-Module 'Azure'
Get-AzureVM | Select ResourceGroupName, Name, InstanceSize `
| Out-Gridview -PassThru
Result
I would like to grab the 3rd "td" element in "filterTable". How is this done in a .NET environment like Powershell ? I have tried numerous ways, like so:
$_.getElementsByTagName("td")[3]
$_.getElementsByTagName("td[3]")
$_.getElementsByTagName("td:3")
$_.getElementsByTagName("td{3}")
$_.getElementsByTagName("td"){3}
However none of these seem to work. Is there a way to do this? Thanks for any help. Here is some context of my code:
$textValues = #()
$textValues = $data.ParsedHtml.getElementById("filterTable") | foreach{
$_.getElementsByTagName("td") | foreach{
$_ | Select InnerText
}
}
You can use the item() method on the element collection returned by getElementsByTagName().
Just supply an index (zero-based):
$filterTable = $data.ParsedHtml.getElementById("filterTable")
$3rdTD = $filterTable.getElementsByTagName("td").item(2)
Alternatively, use Select-Object -Index:
$filterTable.getElementsByTagName("td") |Select-Object -Index 2
I am looking to add a line(s) into a PowerShell script. I want to get my script to check if something exists in a CSV it will give a true/false response.
Basically I have a script to remove user access from O365 and AD including and mailbox changes.
My company also uses a lot of external portals which need removing manually.
I would like it to check the $EmailAddress input against CSV's (i.e DomainHostAccess.CSV, WebsiteHostAccess.CSV, SupplierAccess.Csv) then if there name is in the list it will output something similar to;
DomainHostAccess | True
WebsiteHostAccess | False
SupplierAccess | True
that way we know that we need to manually log into these services and remove accounts.
I have looked on the posts on here already and couldn't find anything suitable, I am fairly new to PS and this is a little advance for me so I would appreciate any help that can be given.
You could try something like this
$UserList = Import-Csv -Path C:\EmailAddress.CSV
$UserData = Import-Csv -Path C:\DomainHostAccess.CSV
ForEach ($Email in $UserList)
{
$userMatch = $UserData | where {$_.Name -like $Email.Name}
If($userMatch)
{
Write-host $Email.Name "Domain Access True"
}
Else
{
Write-host $Email.Name "Domain Access False"
}
}
You would need to have headers on your CSVs for this check to work.