office 365
280 TopicsUsing the <Start-ADSyncSyncCycle -PolicyType Delta> command remotely.
Hello all, I have an Exchange Hybrid between Office 365 and Exchange 2013 on-prem. For this to work we have the Azure AD Connect application installed on the Exchange server. It syncs every half hour and in order to force a sync, as needed in certain situations, we login to the server remotely and run the command <Start-ADSyncSyncCycle -PolicyType Delta> to force a sync. Works everytime and this makes sure that the Active Directory users attributes related to mailbox parameters are copied between the cloud and on-prem. I have tried initiating a remote Exchange Powershell session from other Exchange servers using <Import-PSSession> and <Enter-PSSession> after creating a New-PSSession. This all works but I get an error when I run the command <Start-ADSyncSyncCycle -PolicyType Delta> in both Import and Enter PSSession options. Any Ideas on what I am doing wrong would be greatly appreciated. I am new to the ocean of Powershell so I am pretty sure it is user error on my part. ThanksSolved279KViews0likes4CommentsBulk update Azure AD with user attributes from CSV
I am looking for a way to update user attributes (OfficePhone and Department) for about 500 users from a CSV to AzureAD using a powershell. Does anyone know of a script that I could use? I am new here and if I have not given enough information, please let me know. I tried using Set-AzureADUser piping records using a foreach statement from a csv that I imported, but it was throwing up errors. Thanks! JacobSolved199KViews5likes72CommentsWARNING: Source Location 'https://www.powershellgallery.com/api/v2/package/.....' is not valid
Hello, I was trying install the PowerShell Module to a server and getting error message with not valid url. Debug log attached. PS C:\windows\system32> Install-Module SharePointPnPPowerShellOnline -Force -Debug DEBUG: 00:00:00.0000002 Calling New() : MethodName = 'GetDynamicOptions' Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a DEBUG: 00:00:00.0000300 Force: True DEBUG: 00:00:00.0000445 Debug: True DEBUG: 00:00:00.0000573 Name: SharePointPnPPowerShellOnline DEBUG: 00:00:00.0011177 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1 DEBUG: 00:00:00.0019006 In PowerShellGet Provider - 'Get-DynamicOptions'. DEBUG: 00:00:00.0039875 Done calling powershell «Get-DynamicOptions» «PSModule» DEBUG: 00:00:00.0100688 Calling New() : MethodName = 'GetDynamicOptions' DEBUG: 00:00:00.0100914 Force: True DEBUG: 00:00:00.0101568 Debug: True DEBUG: 00:00:00.0101735 Name: SharePointPnPPowerShellOnline DEBUG: 00:00:00.0109507 INVOKING PowerShell Fn Get-DynamicOptions with args Source that has length 1 DEBUG: 00:00:00.0115616 In PowerShellGet Provider - 'Get-DynamicOptions'. DEBUG: 00:00:00.0144311 Done calling powershell «Get-DynamicOptions» «PSModule» DEBUG: 00:00:00.0181073 Calling New() : MethodName = 'GetDynamicOptions' DEBUG: 00:00:00.0181315 Force: True DEBUG: 00:00:00.0181464 Debug: True DEBUG: 00:00:00.0181607 Name: SharePointPnPPowerShellOnline DEBUG: 00:00:00.0188111 INVOKING PowerShell Fn Get-DynamicOptions with args Package that has length 1 DEBUG: 00:00:00.0194829 In PowerShellGet Provider - 'Get-DynamicOptions'. DEBUG: 00:00:00.0243662 Done calling powershell «Get-DynamicOptions» «PSModule» DEBUG: 00:00:00.0276450 Calling New() : MethodName = 'GetDynamicOptions' DEBUG: 00:00:00.0276668 Force: True DEBUG: 00:00:00.0276801 Debug: True DEBUG: 00:00:00.0276931 Name: SharePointPnPPowerShellOnline DEBUG: 00:00:00.0284428 INVOKING PowerShell Fn Get-DynamicOptions with args Install that has length 1 DEBUG: 00:00:00.0290814 In PowerShellGet Provider - 'Get-DynamicOptions'. DEBUG: 00:00:00.0338093 Done calling powershell «Get-DynamicOptions» «PSModule» DEBUG: 00:00:02.4736146 Calling SearchForPackages. Name='SharePointPnPPowerShellOnline' VERBOSE: Using the provider 'PowerShellGet' for searching packages. Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a DEBUG: 00:00:02.4747220 PackageProvider::FindPackage with name SharePointPnPPowerShellOnline DEBUG: 00:00:02.4749508 Calling SearchForPackages After Select 1 DEBUG: 00:00:07.4799484 Calling New() : MethodName = 'FindPackage' DEBUG: 00:00:07.4800187 ProviderName: PowerShellGet DEBUG: 00:00:07.4800527 Type: Module DEBUG: 00:00:07.4800683 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString DEBUG: 00:00:07.4801181 Force: True DEBUG: 00:00:07.4801320 Debug: True DEBUG: 00:00:07.4801456 Scope: AllUsers DEBUG: 00:00:07.4801619 Name: SharePointPnPPowerShellOnline DEBUG: 00:00:07.4810098 INVOKING PowerShell Fn Find-Package with args System.String[], , , that has length 4 DEBUG: 00:00:07.4832297 In PowerShellGet Provider - 'Find-Package'. DEBUG: 00:00:07.4839335 OPTION: ProviderName => PowerShellGet DEBUG: 00:00:07.4841374 OPTION: Type => Module DEBUG: 00:00:07.4843299 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString DEBUG: 00:00:07.4848048 OPTION: Force => True DEBUG: 00:00:07.4849908 OPTION: Debug => True DEBUG: 00:00:07.4851678 OPTION: Scope => AllUsers DEBUG: 00:00:07.4853432 OPTION: Name => SharePointPnPPowerShellOnline VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories. VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'. VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'. DEBUG: 00:00:07.4907353 PackageProvider::FindPackage with name SharePointPnPPowerShellOnline DEBUG: 00:00:07.4932458 Calling 'NuGet'::'FindPackage' - name='SharePointPnPPowerShellOnline', requiredVersion='',minimumVersion='', maximumVersion='''. DEBUG: 00:00:07.4932826 Iterating 'SharePointPnPPowerShellOnline'. DEBUG: 00:00:07.4935582 There are '0' registered sources in 'NuGet' provider. DEBUG: 00:00:07.4936600 Source 'https://www.powershellgallery.com/api/v2' is not one of the registered sources in 'NuGet' provider. DEBUG: 00:00:09.6490403 Source 'https://www.powershellgallery.com/api/v2' is validated. DEBUG: 00:00:09.6491100 Calling 'NuGetRequest'::'GetPackageById', 'SharePointPnPPowerShellOnline'. DEBUG: 00:00:10.9249696 Calling 'HttpClientPackageRepository'::'FindPackagesById', 'SharePointPnPPowerShellOnline'. DEBUG: 00:00:10.9250551 Calling 'NuGetClient'::'FindPackage'. VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'' for ''. DEBUG: 00:00:10.9253313 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=0&$top=40'. DEBUG: 00:00:12.6410092 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=0&$top=40'. DEBUG: 00:00:12.6506047 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=80&$top=40'. DEBUG: 00:00:12.6506065 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=40&$top=40'. DEBUG: 00:00:12.6506379 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=120&$top=40'. DEBUG: 00:00:12.6508283 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=160&$top=40'. DEBUG: 00:00:13.9261883 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=120&$top=40'. DEBUG: 00:00:13.9265741 '0' packages received in the last request. DEBUG: 00:00:14.6035386 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=80&$top=40'. DEBUG: 00:00:14.6036603 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=160&$top=40'. DEBUG: 00:00:14.6038273 '0' packages received in the last request. DEBUG: 00:00:14.6039490 '0' packages received in the last request. DEBUG: 00:00:15.6130985 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=40&$top=40'. DEBUG: 00:00:15.6178721 '30' packages received in the last request. VERBOSE: Total package yield:'1' for the specified package 'SharePointPnPPowerShellOnline'. DEBUG: 00:00:15.6207643 Completed iterating for 'SharePointPnPPowerShellOnline'. DEBUG: 00:00:15.6470655 Done calling powershell «Find-Package» «PSModule» DEBUG: 00:00:15.6537227 Calling New() : MethodName = 'GetInstalledPackages' DEBUG: 00:00:15.6537527 ProviderName: PowerShellGet DEBUG: 00:00:15.6537681 Type: Module DEBUG: 00:00:15.6537823 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString DEBUG: 00:00:15.6537965 Force: True DEBUG: 00:00:15.6538090 Debug: True DEBUG: 00:00:15.6538215 Scope: AllUsers DEBUG: 00:00:15.6538346 Name: SharePointPnPPowerShellOnline DEBUG: 00:00:15.6543655 INVOKING PowerShell Fn Get-InstalledPackage with args SharePointPnPPowerShellOnline, 3.19.2003.0, , that has length 4 DEBUG: 00:00:15.6550981 In PowerShellGet Provider - 'Get-InstalledPackage'. DEBUG: 00:00:15.6553113 OPTION: ProviderName => PowerShellGet DEBUG: 00:00:15.6554848 OPTION: Type => Module DEBUG: 00:00:15.6556921 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString DEBUG: 00:00:15.6558915 OPTION: Force => True DEBUG: 00:00:15.6560733 OPTION: Debug => True DEBUG: 00:00:15.6562478 OPTION: Scope => AllUsers DEBUG: 00:00:15.6564270 OPTION: Name => SharePointPnPPowerShellOnline DEBUG: 00:00:17.6364439 PowerShell Script 'PSModule' Function 'Get-InstalledPackage' returns null. DEBUG: 00:00:17.6372045 Done calling powershell «Get-InstalledPackage» «PSModule» Confirm Are you sure you want to perform this action? Performing the operation "Install Package" on target "Package 'SharePointPnPPowerShellOnline' version '3.19.2003.0' from 'PSGallery'.". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): a DEBUG: 00:00:42.9836594 Calling New() : MethodName = 'InstallPackage' DEBUG: 00:00:42.9836941 ProviderName: PowerShellGet DEBUG: 00:00:42.9837229 Type: Module DEBUG: 00:00:42.9837425 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString DEBUG: 00:00:42.9837575 Force: True DEBUG: 00:00:42.9837714 Debug: True DEBUG: 00:00:42.9837853 Scope: AllUsers DEBUG: 00:00:42.9837996 Name: SharePointPnPPowerShellOnline DEBUG: 00:00:42.9845292 INVOKING PowerShell Fn Install-Package with args NuGet|SharePointPnPPowerShellOnline|3.19.2003.0|https://www.powershellgallery.com/api/v2|Module that has length 1 DEBUG: 00:00:42.9862372 In PowerShellGet Provider - 'Install-Package'. DEBUG: 00:00:42.9869454 In PowerShellGet Provider - 'Install-PackageUtility'. DEBUG: 00:00:42.9871604 The FastPackageReference is 'NuGet|SharePointPnPPowerShellOnline|3.19.2003.0|https://www.powershellgallery.com/api/v2|Module'. DEBUG: 00:00:42.9875296 OPTION: ProviderName => PowerShellGet DEBUG: 00:00:42.9878200 OPTION: Type => Module DEBUG: 00:00:42.9880217 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString DEBUG: 00:00:42.9882389 OPTION: Force => True DEBUG: 00:00:42.9884634 OPTION: Debug => True DEBUG: 00:00:42.9887816 OPTION: Scope => AllUsers DEBUG: 00:00:42.9889883 OPTION: Name => SharePointPnPPowerShellOnline VERBOSE: The installation scope is specified to be 'AllUsers'. VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'. DEBUG: 00:00:42.9903760 ArtfactType is Module VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'. VERBOSE: Downloading module 'SharePointPnPPowerShellOnline' with version '3.19.2003.0' from the repository 'https://www.powershellgallery.com/api/v2'. DEBUG: 00:00:44.6681094 Calling 'NuGet'::'InstallPackage', '$aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\U2hhcmVQb2ludFBuUFBvd2VyU2hlbGxPbmxpbmU=\My4xOS4yMDAzLjA=\aH R0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\cG93ZXJzaGVsbGdldA=='. DEBUG: 00:00:44.6683081 Calling 'NuGetRequest'::'GetPackageByFastpath', '$aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\U2hhcmVQb2ludFBuUFBvd2VyU2hlbGxPbmxpbmU=\My4xOS4yMDAzLjA=\aH R0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\cG93ZXJzaGVsbGdldA=='. DEBUG: 00:00:44.6684489 Calling 'NuGetRequest'::'ResolvePackageSource', 'https://www.powershellgallery.com/api/v2'. DEBUG: 00:00:44.6684779 Calling 'NuGetRequest'::'FindRegisteredSource', 'https://www.powershellgallery.com/api/v2'. DEBUG: 00:00:44.6685047 Source 'https://www.powershellgallery.com/api/v2' is not one of the registered sources in 'NuGet' provider. DEBUG: 00:00:48.8501172 Calling 'HttpClientPackageRepository'::'FindPackage', 'SharePointPnPPowerShellOnline'. DEBUG: 00:00:48.8501805 Calling 'NuGetClient'::'FindPackage'. VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'' for ''. DEBUG: 00:00:48.8502893 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=0&$top=40'. DEBUG: 00:00:52.1960762 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=0&$top=40'. DEBUG: 00:00:52.2099144 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=40&$top=40'. DEBUG: 00:00:52.2100909 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=120&$top=40'. DEBUG: 00:00:52.2100942 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=80&$top=40'. DEBUG: 00:00:52.2101002 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=160&$top=40'. DEBUG: 00:00:53.6597300 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=80&$top=40'. DEBUG: 00:00:53.6599788 '0' packages received in the last request. DEBUG: 00:00:54.1614418 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=120&$top=40'. DEBUG: 00:00:54.1614464 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=160&$top=40'. DEBUG: 00:00:54.1616464 '0' packages received in the last request. DEBUG: 00:00:54.1618585 '0' packages received in the last request. DEBUG: 00:00:55.6163522 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SharePointPnPPowerShellOnline'&$skip=40&$top=40'. DEBUG: 00:00:55.6251832 '30' packages received in the last request. DEBUG: 00:00:55.6271792 'Package version' is '3.19.2003.0'. DEBUG: 00:00:55.6272337 'Request's Destination' is 'C:\Users\kvanoop\AppData\Local\Temp\398316225'. DEBUG: 00:00:55.6272632 Calling 'NuGetClient'::'GetPackageDependencies'. DEBUG: 00:00:55.6273996 Returning the call 'NuGetClient'::'GetPackageDependencies'. DEBUG: 00:00:55.6275763 Calling 'NuGetClient'::'InstallPackage'. VERBOSE: InstallPackage' - name='SharePointPnPPowerShellOnline', version='3.19.2003.0',destination='C:\Users\kvanoop\AppData\Local\Temp\398316225' VERBOSE: DownloadPackage' - name='SharePointPnPPowerShellOnline', version='3.19.2003.0',destination='C:\Users\kvanoop\AppData\Local\Temp\398316225\SharePointPnPPowerShellOnline\SharePoi ntPnPPowerShellOnline.nupkg', uri='https://www.powershellgallery.com/api/v2/package/SharePointPnPPowerShellOnline/3.19.2003' VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/SharePointPnPPowerShellOnline/3.19.2003'. VERBOSE: An error occurred while sending the request. DEBUG: 00:00:57.0212206 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.PackageManagement.NuGetProvider.NuGetClient.<DownloadDataToFileAsync>d__15.MoveNext() VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/package/SharePointPnPPowerShellOnline/3.19.2003' for '2' more times VERBOSE: An error occurred while sending the request. DEBUG: 00:00:57.8874097 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.PackageManagement.NuGetProvider.NuGetClient.<DownloadDataToFileAsync>d__15.MoveNext() VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/package/SharePointPnPPowerShellOnline/3.19.2003' for '1' more times VERBOSE: An error occurred while sending the request. DEBUG: 00:00:58.7402606 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.PackageManagement.NuGetProvider.NuGetClient.<DownloadDataToFileAsync>d__15.MoveNext() VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/package/SharePointPnPPowerShellOnline/3.19.2003' for '0' more times VERBOSE: Downloading package 'SharePointPnPPowerShellOnline' failed, please make sure 'https://www.powershellgallery.com/api/v2/package/SharePointPnPPowerShellOnline/3.19.2003' is accessable. WARNING: Source Location 'https://www.powershellgallery.com/api/v2/package/SharePointPnPPowerShellOnline/3.19.2003' is not valid. Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a PS C:\windows\system32>Solved152KViews0likes13CommentsThreat Hunting with PowerShell - Security even with a small budget - there is no excuse!
Dear Threat Hunter, Lack of IT security is often excused by little or no available money. In my view, this is a very poor excuse. In this article I will try to give you a jump start on how to investigate threats with PowerShell. Is this a comprehensive and conclusive list of how you can find or detect threats/threats? NO, absolutely not. But it is meant to provide you with the support that you need to move forward on your own. Let's talk about the "general conditions": 1. If you use the PowerShell scripts I show/explain in this article, this is entirely your responsibility. I use the scripts in different situations, they are not dangerous, but you should already know what you are doing. 2. Written permission! If you are not sure if you are allowed to do an investigation, organize a written permission from your supervisor. 3. In the different scripts I sometimes (for this article deliberately) use standard search words like "malware", "malicious", "hacker" etc. Such search patterns/search words need to be customized, of course. These simply serve as an example. 4. The last part of the article examines some Microsoft cloud services. I am absolutely aware that there are a huge number of tools for hunting in the Microsoft cloud services. It starts with Azure Sentinel and continues with Cloud App Security. Since the focus is on a small budget, I'll leave those tools on the side. Introduction: So first, why should you use PowerShell for threat hunting? PowerShell is a useful threat hunting tool because it is a powerful scripting language and a platform for automating tools and accessing data across any Windows environment. It allows you to quickly gather information from various sources such as event logs, registries, files, and processes. Additionally, it can also be easily integrated with other tools and technologies making it a flexible and efficient tool for threat hunting. Some common use cases for PowerShell in the threat hunting environment include automated collection of log data, identification of unusual behavior anomalies in the system, the discovery of malware or malicious activity by known signatures or patterns or behaviors. These are just a few examples of how PowerShell can be used in a threat hunting capacity. Its versatility and ability to access and manipulate data from across the Windows environment make it a very valuable tool for any security professional. Threat Hunting in PowerShell - Use Cases: All right. So now that we understand where PowerShell can benefit an organization from a threat hunting perspective. Let's take a deeper look at some of the actual use cases you might encounter on a day to day basis, first being identify malicious processor files. So specifically, you can conduct raw file analysis to sift through different data shares to look for particular files in question whether that be a signature or even an extension of a certain file being able to quickly search and triage through files is an extreme benefit of using PowerShell for threat hunting. But how exactly do we start, what can we use as a guide? For example, the MITRE ATT&CK Framework. Here are a few examples: Indicator Removal: Clear Windows Event Logs https://attack.mitre.org/techniques/T1070/001/ Event Triggered Execution: Installer Packages https://attack.mitre.org/techniques/T1546/016/ Hide Artifacts: NTFS File Attributes https://attack.mitre.org/techniques/T1564/004/ Command and Scripting Interpreter: PowerShell https://attack.mitre.org/techniques/T1059/001/ Command and Scripting Interpreter: Windows Command Shell https://attack.mitre.org/techniques/T1059/003/ Event Triggered Execution: Windows Management Instrumentation Event Subscription https://attack.mitre.org/techniques/T1546/003/ Credentials from Password Stores: Windows Credential Manager https://attack.mitre.org/techniques/T1555/004/ Abuse Elevation Control Mechanism: Bypass User Account Control https://attack.mitre.org/techniques/T1548/002/ The MITRE ATT@CK framework provides a comprehensive and regularly updated overview of tactics, techniques, and procedures (TTPs) used by various threat actors. We can locate these TTPs using PowerShell, here are a few examples: Indicator Removal: Clear Windows Event Logs https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/06_Account_Events.ps1 Event Triggered Execution: Installer Packages https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/08_Get-ItemProperty_Software.ps1 Hide Artifacts: NTFS File Attributes https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/08_Get-ItemProperty_Software.ps1 Windows Installer Service is running https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/01_WIS_is_running.ps1 Search Alternate Data Streams on NTFS File Systems https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/02_Search_ADS_on_NTFS%20_(specific%20file).ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/03_Search_ADS_on_NTFS_file_systems.ps1 Read the Contents of a File https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/06_Read_the_contents_file.ps1 Locating Data Patterns within a File https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/05_locating_data_patterns_within_file.ps1 Search for Encoding with Regex https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/07_Search_encoding_with_regex.ps1 Search for Command and Scripting Interpreter: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/04_Searching_for_PIDs.ps1 Threat hunting in different environments with PowerShell: Coming examples are about collecting information in very different environments. Also here a few examples as a kind => as first starting points: Hunt for Threats in Active Directory: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/01_Resetting_Password_Unlocking_Accounts.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/02_Search_stale_accounts.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/03_Users_without_Manager.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/04_Password_Expiration.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/05_Group_Membership_Report.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/06_Account_Events.ps1 https://github.com/tomwechsler/Active_Directory_Advanced_Threat_Hunting/blob/main/PowerShell/Tracking_the_Source_of_Account_Lock_Outs_and_Bad_Passwords.ps1 https://github.com/tomwechsler/Active_Directory_Advanced_Threat_Hunting/blob/main/PowerShell/Finding_Unused_Group_Policy_Objects.ps1 Some of the scripts are structured in such a way that they must be executed block by block/line by line. So do not execute the whole script at once. Pay attention to the different information that is collected. With some investigations in the Active Directory accounts can be indicated like "guest" or "krbtgt", there must be clear of course how this information is to be estimated. Depending on how and what information is searched. Hunt for Threats in Exchange Online: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Exchange_Online/Exchange_Mailbox_LastLogin.ps1 Find mailboxes with the last login. Hunt for Threats in Azure: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Azure/Collect_vms_subscription.ps1 We search Azure for all virtual machines in a subscription. https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Azure/02_Graph_Create_Time_Last_Password.ps1 When was the last password change and when were the accounts created? Hunt for Threats in SharePoint: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_SharePoint_Online/SharePoint_Online_specific_files.ps1 With this script we search for files with the extension .ps1 in a SharePoint Online page. Summary: Is this the best tactic to hunt for threats? No! There are many different tactics/techniques to search for threats. First of all, there are a huge number of different tools that can be used, for example SIEM/SOAR (Security Information and Event Management/Security Orchestration, Automation and Response). These tools are really great, sometimes cost a lot and often it takes a lot of knowledge to use such tools. But what is the use of such tools if the information generated by these tools cannot be understood properly, not very much. For this reason, I have tried in this article with simple tools to generate information that hopefully can be interpreted. Is finished here at this point. NO, the journey continues. The examples in this article are neither exhaustive nor complete, but they should give you a starting point. I hope you can build on this foundation. I hope that this information is helpful to you and that you have received a good "little" foundation. But I still hope that this information is helpful for you. Thank you for taking the time to read the article. Happy Hunting, Tom Wechsler P.S. All scripts (#PowerShell, Azure CLI, #Terraform, #ARM) that I use can be found on github! https://github.com/tomwechsler63KViews5likes0CommentsIdentifying Read status of emails in Exchange Online / Office 365
So I cant find an answer to this, Im trying to find a way in powershell to report on read status of mail from a sender. Id like to reiterate, I want to find a way to report on READ STATUS of mail in Office 365/Exchange Online. I know I can carry out Get-MessageTrace to get the delivery status and Get-MessageTraceDetail . I know you can use Search-MessageTrackingReport to query on prem solution but I cant for the life of me find a way to do this for a cloud deployment. According to Microsoft the Search-MessageTrackingReport was replaced with Get-MessageTrace and Get-MessageTraceDetail for online solutions. But as far as I can tell it does not have the same functionality. ref: https://practical365.com/exchange-server/tracking-read-email-messages-exchange-server/ (shows how to use Search-MessageTrackingReport to identify READ status.49KViews0likes2CommentsThreat Hunting with PowerShell - Security even with a small budget - there is no excuse!
Dear Threat Hunter, Lack of IT security is often excused by little or no available money. In my view, this is a very poor excuse. In this article I will try to give you a jump start on how to investigate threats with PowerShell. Is this a comprehensive and conclusive list of how you can find or detect threats/threats? NO, absolutely not. But it is meant to provide you with the support that you need to move forward on your own. Let's talk about the "general conditions": 1. If you use the PowerShell scripts I show/explain in this article, this is entirely your responsibility. I use the scripts in different situations, they are not dangerous, but you should already know what you are doing. 2. Written permission! If you are not sure if you are allowed to do an investigation, organize a written permission from your supervisor. 3. In the different scripts I sometimes (for this article deliberately) use standard search words like "malware", "malicious", "hacker" etc. Such search patterns/search words need to be customized, of course. These simply serve as an example. 4. The last part of the article examines some Microsoft cloud services. I am absolutely aware that there are a huge number of tools for hunting in the Microsoft cloud services. It starts with Azure Sentinel and continues with Cloud App Security. Since the focus is on a small budget, I'll leave those tools on the side. Introduction: So first, why should you use PowerShell for threat hunting? PowerShell is a useful threat hunting tool because it is a powerful scripting language and a platform for automating tools and accessing data across any Windows environment. It allows you to quickly gather information from various sources such as event logs, registries, files, and processes. Additionally, it can also be easily integrated with other tools and technologies making it a flexible and efficient tool for threat hunting. Some common use cases for PowerShell in the threat hunting environment include automated collection of log data, identification of unusual behavior anomalies in the system, the discovery of malware or malicious activity by known signatures or patterns or behaviors. These are just a few examples of how PowerShell can be used in a threat hunting capacity. Its versatility and ability to access and manipulate data from across the Windows environment make it a very valuable tool for any security professional. Threat Hunting in PowerShell - Use Cases: All right. So now that we understand where PowerShell can benefit an organization from a threat hunting perspective. Let's take a deeper look at some of the actual use cases you might encounter on a day to day basis, first being identify malicious processor files. So specifically, you can conduct raw file analysis to sift through different data shares to look for particular files in question whether that be a signature or even an extension of a certain file being able to quickly search and triage through files is an extreme benefit of using PowerShell for threat hunting. But how exactly do we start, what can we use as a guide? For example, the MITRE ATT&CK Framework. Here are a few examples: Indicator Removal: Clear Windows Event Logs https://attack.mitre.org/techniques/T1070/001/ Event Triggered Execution: Installer Packages https://attack.mitre.org/techniques/T1546/016/ Hide Artifacts: NTFS File Attributes https://attack.mitre.org/techniques/T1564/004/ Command and Scripting Interpreter: PowerShell https://attack.mitre.org/techniques/T1059/001/ Command and Scripting Interpreter: Windows Command Shell https://attack.mitre.org/techniques/T1059/003/ Event Triggered Execution: Windows Management Instrumentation Event Subscription https://attack.mitre.org/techniques/T1546/003/ Credentials from Password Stores: Windows Credential Manager https://attack.mitre.org/techniques/T1555/004/ Abuse Elevation Control Mechanism: Bypass User Account Control https://attack.mitre.org/techniques/T1548/002/ The MITRE ATT@CK framework provides a comprehensive and regularly updated overview of tactics, techniques, and procedures (TTPs) used by various threat actors. We can locate these TTPs using PowerShell, here are a few examples: Indicator Removal: Clear Windows Event Logs https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/06_Account_Events.ps1 Event Triggered Execution: Installer Packages https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/08_Get-ItemProperty_Software.ps1 Hide Artifacts: NTFS File Attributes https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/08_Get-ItemProperty_Software.ps1 Windows Installer Service is running https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/01_WIS_is_running.ps1 Search Alternate Data Streams on NTFS File Systems https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/02_Search_ADS_on_NTFS%20_(specific%20file).ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/03_Search_ADS_on_NTFS_file_systems.ps1 Read the Contents of a File https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/06_Read_the_contents_file.ps1 Locating Data Patterns within a File https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/05_locating_data_patterns_within_file.ps1 Search for Encoding with Regex https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/07_Search_encoding_with_regex.ps1 Search for Command and Scripting Interpreter: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Tactics_Techniques_Procedures_(TTPs)/04_Searching_for_PIDs.ps1 Threat hunting in different environments with PowerShell: Coming examples are about collecting information in very different environments. Also here a few examples as a kind => as first starting points: Hunt for Threats in Active Directory: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/01_Resetting_Password_Unlocking_Accounts.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/02_Search_stale_accounts.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/03_Users_without_Manager.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/04_Password_Expiration.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/05_Group_Membership_Report.ps1 https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Active_Directory/06_Account_Events.ps1 Some of the scripts are structured in such a way that they must be executed block by block/line by line. So do not execute the whole script at once. Pay attention to the different information that is collected. With some investigations in the Active Directory accounts can be indicated like "guest" or "krbtgt", there must be clear of course how this information is to be estimated. Depending on how and what information is searched. Hunt for Threats in Exchange Online: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Exchange_Online/Exchange_Mailbox_LastLogin.ps1 Find mailboxes with the last login. Hunt for Threats in Azure: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Azure/Collect_vms_subscription.ps1 We search Azure for all virtual machines in a subscription. https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_Azure/02_Graph_Create_Time_Last_Password.ps1 When was the last password change and when were the accounts created? Hunt for Threats in SharePoint: https://github.com/tomwechsler/Threat_Hunting_with_PowerShell/blob/main/Hunting_SharePoint_Online/SharePoint_Online_specific_files.ps1 With this script we search for files with the extension .ps1 in a SharePoint Online page. Summary: Is this the best tactic to hunt for threats? No! There are many different tactics/techniques to search for threats. First of all, there are a huge number of different tools that can be used, for example SIEM/SOAR (Security Information and Event Management/Security Orchestration, Automation and Response). These tools are really great, sometimes cost a lot and often it takes a lot of knowledge to use such tools. But what is the use of such tools if the information generated by these tools cannot be understood properly, not very much. For this reason, I have tried in this article with simple tools to generate information that hopefully can be interpreted. Is finished here at this point. NO, the journey continues. The examples in this article are neither exhaustive nor complete, but they should give you a starting point. I hope you can build on this foundation. I hope that this information is helpful to you and that you have received a good "little" foundation. But I still hope that this information is helpful for you. Thank you for taking the time to read the article. Happy Hunting, Tom Wechsler P.S. All scripts (#PowerShell, Azure CLI, #Terraform, #ARM) that I use can be found on github! https://github.com/tomwechsler47KViews0likes0CommentsUnable to connect to Exchange Online (Powershell) with MFA
Anyone see this error when attempting to connect to Exchange Online with MFA? out-lineoutput : The method or operation is not implemented. + CategoryInfo : NotSpecified: (:) [out-lineoutput], NotImplementedException + FullyQualifiedErrorId : System.NotImplementedException,Microsoft.PowerShell.Commands.OutLineOutputCommand Installed the hybrid exchange module from Exchange Online as I have always done. Also installed other AzureAD and seeing the same error (i.e Get-MSOLuser) The only thing i believe is different this round was that I installed Powershell 5.1 (and even 6.1.2 thinking it might have been a bug). Help38KViews0likes11CommentsConvert a text string to a correct date time format
Hello folks, I have maybe a simple question for the experienced people around here 🙂 . I have a runbook in azure that is getting the field "CreatedDateTime" of a unified group (Teams Team). The format of this field ist like the following "2020-08-06T06:03:19Z". This is not recognized as a valid DateTime format by the cmdlet: $DateTime=[Datetime]::ParseExact($DateTime, 'MM/dd/yyyy', $null) Can anyone point me to a solution how to get the string "2020-08-06T06:03:19Z" into a string like "2020-08-06" or "06-08-2020". Every hint is appreciated. Thank you all 😉Solved38KViews0likes4CommentsHow to Add / Remove user in existing BookInPolicy In O365 through PowerShell
Hello , I have a Book In Policy for meeting rooms and i need to add and remove users to the existing policy. I have created the policy using the below command Get-Mailbox BoardRoom | Set-CalendarProcessing -AllBookInPolicy:$false -AllRequestInPolicy:$false -BookInPolicy "Email address removed","Email address removed","Email address removed" But when i am running the command to add/remove users it over write the existing policy. I tried the below and it did not work Set-CalendarProcessing -Identity "Room9" -BookInPolicy "Email address removed", "Email address removed" Any help would be appreciated. Thanks, AtulSolved22KViews0likes5CommentsInstall-Module MSOnline - not working
Hi all, I am struggling to install: Install-Module MSOnline I get: I have tried: Get-PSRepository WARNING: Unable to find module repositories. When I run: Register-PSRepository -Default I get no error but when trying to run Get-PSRepository again i get WARNING: Unable to find module repositories. Any ideas on how to fix this?Solved21KViews0likes1Comment