PowerShell CMDLETS
12 TopicsGet AzSentinelDataConnector no output
Hi All, I'm trying to export the list of all the data connectors using powershell module Az Security Insight. when I run the command Get-AzSentinelDataConnector, I have no output PS C:\Users\> Get-AzSentinelDataConnector -ResourceGroupName "Resourcegroup Name" -WorkspaceName "WorkSpace Name" PS C:\Users\> while using the command Get-AzSentinelAlertRuleTemplate I have all the alert rule as output PS C:\Users\> ... Kind : NRT LastUpdatedDateUtc : 30-Aug-22 12:00:00 AM Name : 5db427b2-f406-4274-b413-e9fcb29412f8 Query : AuditLogs | where ActivityDisplayName =~'Add member to role completed (PIM activation)' | where Result == "failure" ... RequiredDataConnector : {AzureActiveDirectory} Severity : High ... PS C:\Users\> Can someone support me? Thanks, lg960Views0likes3CommentsGet-ChildItem and Get-WmiObject cim_datafile showing different results
I am using below code to Check if the server is pinging then for Pingable Servers I am checking the Service Status and a file version but I see Get-ChildItem and Get-WmiObject cim_datafile showing different results. Get-WmiObject cim_datafile showing correct results. Looks like Get-ChildItem giving wrong results because it does not support -computername. any idea how can I use any cmdlet which does not support -computername in this script and still get correct results. function Get-EncaseInfo { [CmdletBinding()] param ( #[Parameter(Mandatory = $True)] #[string[]]$serverName ) process { $servers = (Get-Content D:\IT\servers.txt) $server_error = $false $servers_down = @() $servers_up = @() foreach ($server in $servers) { if(Test-Connection $server -Count 1 -ea 0 -Quiet){ #Write-Host $server "is Pinging" -BackgroundColor Green -ForegroundColor White $servers_up += "$server" }else{ #Write-Host $server "is not Pinging" -BackgroundColor Red -ForegroundColor White $servers_down += "$server" $server_error = $true }} Write-Host "" Write-Host "INFO: Below Servers are up" -ForegroundColor Green Write-output $servers_up if($server_error){ $error_msg = "Below Servers are not Pinging" Write-Host "" Write-Host $error_msg -ForegroundColor Red Write-output $servers_down }else{ Write-Host "INFO: ALL Servers are Pinging" -ForegroundColor Blue -BackgroundColor White} foreach ($Servup in $servers_up){ $Service=Get-Service -Name enstart64 -ComputerName $Servup -ErrorAction SilentlyContinue -ErrorVariable Errs #$EnVer = ((Get-ChildItem C:\Windows\system32\enstart64.exe).VersionInfo).FileVersion $EnVer = (Get-WmiObject cim_datafile -ComputerName $Servup -Filter {Name='C:\\Windows\\system32\\enstart64.exe'}).version [PSCustomObject]@{ 'ComputerName'=$Servup; 'Service'=$Service.Status; 'StartType'=$Service.StartType; 'EnVersion'=$EnVer; 'Error'=$Errs; } } } } Get-EncaseInfo | FT -AutoSize1.1KViews0likes1CommentUnable to run PowerShell cmdlets after module installation
Hi All, I have installed the Sharepoint Online Management Shell module in our remote desktop server. However I am unable to run any cmdlets after the installation is done. The module name isn't visible in the list of modules in the ISE as well. We have tried to install both through Windows INstaller as well as through the Install-Module cmdlet.2.1KViews0likes4CommentsUnable to upgrade to A7 and A8 using Azure PowerShell Cmdlet -
We are using this Cmdlet: https://docs.microsoft.com/en-us/powershell, to Upgrade the SKU to A7 and A8. We are able to scale to A7 from UI as shown below. On trying with PowerShell Cmdlet, we get the below error: Update-AzureRmPowerBIEmbeddedCapacity : Cannot validate argument on parameter 'Sku'. The argument "A7" does not belong to the set "A1,A2,A3,A4,A5,A6" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again. At line:70 char:121 + ... -Name $pbiEmbCap.Name -ResourceGroupName $resourceGroupName -Sku $sku + ~~~~ + CategoryInfo : InvalidData: (:) [Update-AzureRmPowerBIEmbeddedCapacity], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.PowerBI.UpdateAzurePowerBIEmbeddedCapacity Is it possible to update the parameter set including A7 and A8, so that we can use the same Cmdlet to upgrade the SKU888Views0likes1CommentBug in Get-CMSoftwareUpdateDeploymentStatus cmdlet
When I run the Get-CMSoftwareUpdateDeploymentStatus cmdlet I get the following message; Get-CMSoftwareUpdateDeploymentStatus : Operation could not complete because the currently connected account does not have the required security rights to perform this operation. I have the Full Administrator role I can run Get-CMPackageDeployment -DeploymentId "XX12008C" | Get-CMPackageDeploymentStatus and Get-CMApplicationDeployment -DeploymentId "{9462...43F34}" | Get-CMApplicationDeploymentStatus both work flawlessly but I can't do the same for Software Updates I run the following command; Get-CMSoftwareUpdateDeployment -DeploymentId "{7047...d3fe}" | Get-CMSoftwareUpdateDeploymentStatus644Views0likes0CommentsUnable to export all public folder permissions to .CSV
Hello, I've been trying to export a list of every single public folder user's permission to a csv file. Its successful when I use : get-publicfolder -recurse | get-publicfolderclientpermissions | export-csv XXX , however it does only return about 10000 entries. If I add resultsize -unlimited to the above script it returns nothing - the csv file is completely blank. Any ideas? I also need to get a list of permissions to all public folders for a single user ( we've about 1000 of them in our env and user would like to know to which folders he has an access to). In addition it does return the below error now:1.4KViews0likes3CommentsDirect Routing setup still not working or documented
I am currently unable to add new users to our Direct Routing setup in MS Teams. This is broken since the S4B module was deprecated. Some basics... I am running Powershell v5.1 I have installed module Microsoft Teams v2.5.1 I am 'connected' to MicrosoftTeams module as a Global Admin who also has the S4B Admin role assigned (although it should need a separate role assignment). I have 'imported' the Microsoft Teams module I am trying to run: Set-CsUser -Identity "xxxxx@yyyyy.org" -OnPremLineURI tel:+44000000000 -EnterpriseVoiceEnabled $true -HostedVoiceMail $true I receive back: Set-CsUser : The 'Set-CsUser' command was found in the module 'MicrosoftTeams', but the module could not be loaded. For more information, run 'Import-Module MicrosoftTeams' If I try: Set-CsOnlineVoiceUser -Identity "xxxx@yyyy.org" -TelephoneNumber tel:+440000000000 I receive back: Set-CsOnlineVoiceUser : The 'Set-CsOnlineVoiceUser' command was found in the module 'MicrosoftTeams', but the module could not be loaded. For more information, run 'Import-Module MicrosoftTeams' 'Import-Module Microsoft Teams' has already been run and running it again does not provide any additional information. None of the cmdlet reference guides Microsoft have published even list the cmdlets from the S4B module that needed to be used for Enterprise Direct Routing so this leads me to ask... 1) When will Microsoft update the documentation for the new MicrosoftTeams module to include the full cmdlet list? 2) What commands 'should' I be using to add users to our Direct Routing and to grant OnlineVoiceRoutingPolicy (s)? Many thanks in advance to anyone who has the answers.Solved2KViews0likes3CommentsAlternative to invoke-expression
I am looking for alternate way to extract the value of the below powershell object without using invoke-expression invoke-expression "`$abc.properties.$subprop" or invoke-expression "`$abc.$subprop1" Where $abc is a powershell object in JSON format $subprop is having one of the Noteproperties of '$abc.properties'3.8KViews0likes1CommentMicrosoftTeams cmdlets not working with AccessToken
I am trying to run cmdlets from powershell module MicrosoftTeams (version 2.0.0) in a C# web application. I am using Authorization code flow and code from the answer provided in this post to acquire token: Acquire AAD token using ASP.Net web forms. Note: I had changed resource in the code to graph.windows.net to acquire AAD token. Token is acquired by using AuthenticationContext.AcquireTokenByAuthorizationCodeAsync method. Once the token is acquired, I run the following lines to create a powershell instance in C# and to import MicrosoftTeams Module. PowerShell pshell InitialSessionState iss; iss = InitialSessionState.CreateDefault2(); iss.ImportPSModule(new[] { "MicrosoftTeams" }); pshell = PowerShell.Create(iss); Then to connect with MicrosoftTeams, I run the following code: var connectCmd = new Command("Connect-MicrosoftTeams"); connectCmd.Parameters.Add("AadAccessToken", AccessToken); connectCmd.Parameters.Add("AccountId", "xxxxxxx@xxxxxx.onmicrosoft.com"); pshell.Commands.AddCommand(connectCmd); var result1 = pshell.Invoke(); Code works fine till here. After this I clear the shell commands and invoke the Get-CsTeamsCallingPolicy cmdlet: pshell.Commands.Clear(); pshell.Streams.Error.Clear(); pshell.AddScript("Get-CsTeamsCallingPolicy"); var result2 = pshell.Invoke(); After Invoke, I get an exception and this dialog pops up: Pressing 'Continue' brings back the same dialogue a couple of times. Exception details from this screen are: System.Collections.Generic.KeyNotFoundException was unhandled by user code HResult=-2146232969 Message=The given key was not present in the dictionary. Source=mscorlib StackTrace: at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key) at Microsoft.TeamsCmdlets.Powershell.Connect.Models.AzureSessionProvider.GetAccessToken(String resource, IEnumerable`1 scopes) in D:\a\1\s\src\Microsoft.TeamsCmdlets.PowerShell.Connect\Models\AzureSession.cs:line 80 at Microsoft.TeamsCmdlets.Powershell.Connect.TeamsPowerShellSession.GetAccessToken(String resource, IEnumerable`1 scopes) in D:\a\1\s\src\Microsoft.TeamsCmdlets.PowerShell.Connect\TeamsPowerShellSession.cs:line 82 at Microsoft.TeamsCmdlets.PowerShell.Connect.GetCsInternalAccessToken.ProcessRecord() in D:\a\1\s\src\Microsoft.TeamsCmdlets.PowerShell.Connect\GetCsInternalAccessToken.cs:line 61 at System.Management.Automation.CommandProcessor.ProcessRecord() After pressing continue for the 3rd time, control goes back to C# code, and I receive the following runtime exception: Exception calling "GetSteppablePipeline" with "1" argument(s): "Exception calling "GetRemoteNewCsOnlineSession" with "1" argument(s): "Run either Connect-MicrosoftTeams or new-csonlinesession before running cmdlets."" Trying to run this logic from the powershell editor shows similar behavior: Running the following two lines: $AccessToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' Connect-MicrosoftTeams -AadAccessToken $AccessToken -AccountId 'xxxxxxx@xxxxxx.onmicrosoft.com' gives this result: Account Environment Tenant TenantId ------- ----------- ------ -------- xxxxxxx@xxxxxx.onmicrosoft.com AzureCloud xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx I then run Get-Team cmdlet: Get-Team -User xxxxxxx@xxxxxxx.onmicrosoft.com which results in this message: Get-Team : The given key was not present in the dictionary. At line:1 char:1 + Get-Team -User xxxxxxx@xxxxxxx.onmicrosoft.com + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-Team], KeyNotFoundException + FullyQualifiedErrorId : System.Collections.Generic.KeyNotFoundException,Microsoft.TeamsCmdlets.PowerShell.Custom.GetTeam Running cmdlet Get-CsTeamsCallingPolicy yields this: Exception calling "GetSteppablePipeline" with "1" argument(s): "Exception calling "GetRemoteNewCsOnlineSession" with "1" argument(s): "Run either Connect-MicrosoftTeams or new-csonlinesession before running cmdlets."" At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.0.0\net472\SfBORemotePowershellModule.psm1:11369 char:13 + $steppablePipeline = $scriptCmd.GetSteppablePipeline($myI ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : CmdletInvocationException If I run Connect-MicrosoftTeams directly from powershell without providing access token and accountid, I get the login screens and after login everything works fine i.e. I can run Get-Team and Get-CsTeamsCallingPolicy cmdlets successfully but I don't get this behavior when working with AadAccessToken. All the above code works fine if connecting to AzureAD module via Connect-AzureAD cmdlet like this both in web application and powershell editor: Connect-AzureAD -AadAccessToken $AccessToken -AccountId 'xxxxxxx@xxxxxxx.onmicrosoft.com' If someone has faced and successfully resolved this issue or have some tips on how to resolve this, please help. I have already tried a lot of things including searching for the specific exception messages and any possible solutions but found nothing that could help in this particular scenario, installed the latest version of MSTeams module, the previous version was old and did not have all the cmdlets that I am looking to work with. I installed the preview version of MSTeams module also to see if this issue is fixed in the upcoming release. Uninstalled the deprecated SkypeForBuisnessOnline Connector module, updated windows and so on. If you look at Example 4 in the Microsoft documentation for Connect-MicrosoftTeams, this is what I am trying to achieve.2.1KViews1like5Comments"Pre load" Powershell module
My new Powershell module did have a load time of several seconds. Using this in a production environment is not an option with this long load time. Is it possible to add this module to the "core" of powershell. So that it is already loaded before I start a new powershell session? King regards, Hans.Harms@centric.eu5.4KViews0likes6Comments