Powershell Search-UnifiedAuditLog - powershell

Our old script usic Basic authentication to read the O365 Logs doesn't work anymore as MS stopped Basic Authentication. Quite normal.
We would like to rewrite the script using the cmdlet Search-UnifiedAuditLog, that seems to be part of ExchangePowerShell.
But after installing tat module with Install-Module -Name ExchangeOnlineManagement the search cmdlet is not yet available.
Also the Get-Command show far more less cmdlets then the documentation does.
I'm not a Powershell export, could somebody help me out what I'm doing wrong ?
Kr, Harry

As posted this surely was the solution, Thx Mathias

Related

Get-Command -Module MicrosoftTeams does not include Get-TeamChannelUser cmdlet

So, I'm looking to do some powershell automation now that my company is clamoring for Microsoft Teams. I installed the module version 1.0.5 (currently the latest) and I'm seeing documentation on how to add users to team channels.
I get cmdlet not found errors when using those commandlets
Get-TeamChannelUser : The term 'get-teamchanneluser' is not recognized as the name of a cmdlet, function, script file...
Low and behold, get-command -module MicrosoftTeams returns no cmdlets with TeamChannelUser (Get, Remove or Set).
I've tried older versions of the module but I'm still seeing the same symptom. Is anyone else able to reproduce this? Any workarounds?
I haven't tested this specifically, but have you looked into the new (pre-release) Microsoft Graph PowerShell module? It includes a lot of "Teams" functions, but also of course more broad "Graph" capabilities, which is important (recall that Teams relies on SharePoint, Groups, etc.).
I had to manually install a test version 1.0.21, but now when I run the Get-Command, I see the ChannelUser cmdlets.
Thanks to Hilton Giesenow, I'm going to try his suggestion as well and will mark it as the answer if it works better and post an update.
I struggled to get this working. I ended up installing 1.1.3.
This is what worked for me:
PS C:\WINDOWS\system32> Install-Module -Name MicrosoftTeams -RequiredVersion 1.1.3-preview -AllowPrerelease -force -AllowClobber
PS C:\WINDOWS\system32> Import-Module microsoftteams
PS C:\WINDOWS\system32> get-command -Module microsoftteams

Not able to get New-F5Item cmdlet

I am creating a pool in F5.
i came across the below link which gives a function of creating a Pool.
(https://www.powershellgallery.com/packages/f5-ltm/1.4.154/Content/Public%5CNew-Pool.ps1)
All the things are fine. i have installed F5-LTM module for powershell also.
Install-Module -Name F5-LTM -RequiredVersion 1.4.280
I am not able to see the "New-F5Item" cmdlts.
Can you please let me know about this cmdlet.
Thank you
If you look at the file list in PSGallery, you'll notice that the package contains the script file Private\New-F5Item.ps1, indicating that New-F5Item is probably not exported by the module.
When a command is not exported, it can only be discovered/called from other functions in the same module - which is why you don't see it when doing Get-Command or similar.

Is it possible to delete or overwrite cmdlets?

I'm working with DNS resource records in Powershell 5 using code that I inherited from the guy who was trying to do this before me. The cmdlet I am trying to use is Add-DnsServerResourceRecordA.
Part of his code has import-module certain folder\PowerShell\Modules\DnsServer. The weird thing is, it seems like as I was trying bits and pieces of the code earlier, I was able to use the add-DNSblah cmdlet. Now, after It ried running the whole script including the import-module, Powershell is saying that the cmdlet does not exist natively, and when I import the module and run it it is giving me Add-DnsServerResourceRecordA: Invalid Class.
It is my understanding that Add-DnsServerResourceRecordA should be included in my normal Powershell 5.0. Could that Import-Module have permanently damaged PS somehow? Why else would the cmdlet not show up, even in a Get-Command "dns"?
I'm pretty sure you will need the Remote Server Administration Tools (RSAT) installed to have these cmdlets available on a non-server Windows OS.
You can download them from this page: https://www.microsoft.com/en-gb/download/details.aspx?id=45520.
Not really sure why the Import-Module does not fail if the DNSServer module is not present on the system.
If RSAT are already installed, you can try to reinstall them.

Get-Help cannot find the Help files for ServiceFabric module

I installed the Azure Service Fabric SDK and I wanted to get some help information on some of the commands:
Get-Help Connect-ServiceFabricCluster
It returns the following output under remarks:
REMARKS
Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
-- To download and install Help files for the module that includes this cmdlet, use Update-Help.
I ran Update-Help -Module ServiceFabric in an administrator window and I still get this error.
How can I get the help to work for the ServiceFabric powershell commands?
I just ran Update-Help successfully from an admin window, are you still seeing this problem? You could try running Update-Help -Module ServiceFabric -Force to force update.
Sounds like an issues with PowerShell Update-Help. This post provides a little more info and a workaround.
I had a similar issue with core commands, i.e. I couldn't get detailed help for Get-Command.
In my case it helped specifying the locale to en-US when running Update-Help as there seems to be a Problem with the fallback to en-US when no other help files can be found.
Command it worked with:
Update-Help -UICulture en-US
See also:
https://github.com/PowerShell/PowerShell/issues/6217

Suppressing VERBOSE for Import-Module

I'm importing Carbon into my PowerShell script; however when running my script with -Verbose, Carbon also outputs a lot of VERBOSE statements.
Is it possible to Import-Module silently such that I can ignore the verbose statements in the imported module and leave just my own?
Try Import-Module Carbon -Verbose:$false
I could not get the solutions above to work with all modules (I'm using Powershell 4.0). This is the solution I ended up using and so far it has worked with every module I've used:
At the top of my script file I have this, to make the -Verbose work for the script (the script has no parameters):
[CmdletBinding()]
Param()
Then when I'm ready to import the modules, I do this:
$SaveVerbosePreference = $global:VerbosePreference;
$global:VerbosePreference = 'SilentlyContinue';
Import-module "Whatever";
$global:VerbosePreference = $SaveVerbosePreference;
Then I just call the script like so:
PowerShell -file something.ps1 -Verbose
Import-Module Carbon -Verbose:$false | Out-Null
I think a better solution than the one which is marked here is to redirect the verbose output to a different stream. This way you can print the output if you need it and it doesn't get swollen for ever:
Import-Module Carbon 4>&5
This redirects the verbose stream (4) to the debug stream (5). When you run your script with the Verbose switch, it will not output the verbose lines from Import-Module, but you can bring it back by running your script with the -Debug switch.
As Carbon seems to be a script module, can you try to set the $script:VerbosePreference (or just $VerbosePreference) to 'SilentlyContinue' inside the module itself carbon.psm1. The module scope should do the trick.
First contribution, I hope this helps.
ipmo $dir\$i 3>$null
ipmo: Short-hand/alias for Import-Module
3>$null: Redirect warnings messages to null
Edit:
I wanted to share a table I found at work while I was looking for the best way to help explain this... But I cant find it now. However, the quick an dirty is you may have already noticed that ipmo doesn't act like the rest of those PWshell cmdlet. It has a total of 4 streams in the bg.
I don't remember 1 and 2. 3 is warning. 4 though, 4 is not necessarily error, but it is error at the same time? I don't remember the exact wording. It is something that bypasses errors.
If I do find that award winning table again I'll be sure to share the blessing.