Latest Discussions
is there a bug in bytes
There are multiple scripts involving creating Magic Packets for WOL. Basically, all consist of code creating a byte array and sending it via System.Net.Sockets.UdpClient with the 2nd parameter of the send command as the length of the packet. According to the WOL docs the length should be 102 bytes. The math works for some MAC addresses but gives 86 for others. Test below [PS 5.1 ISE]. The point being would a length of 86 still work with WOL uncomment as needed to test $MAC = "1A:2B:3C:4D:5E:6F" #should give 102 #$MAC = "74:86:31:7D:19" #should give 86 #$MAC = "1A:86:3C:7D:6F" #should give 102, but try your own to test #$ByteArray = $MAC -replace "[:\-]" -split "(..)" -ne '' | ForEach-Object { [Byte] "0x$_"} $ByteArray = $MAC -split ":" | ForEach-Object { [Byte] "0x$_"} [Byte[]] $MagicPacket = (,0xFF * 6) + ($ByteArray * 16) $MagicPacket.Length P.S. Tested determining the length in other languages and all came out 102.StanLDec 03, 2024Copper Contributor3Views0likes0CommentsRemote execution with exchange powershell
I'm trying to extract the primarysmtpaddress of each member of a distribution group from an exchange server in a remote forest. The bulk of the script is something link this $parameters = @{ ConfigurationName = 'Microsoft.Exchange' ConnectionUri = 'http://srvwex.company.local/powershell' Credential = $sourceCred # Authentication = 'Basic' ScriptBlock = {{(Get-DistributionGroup $args[0] |Get-DistributionGroupMember).PrimarySmtpAddress }} ArgumentList = $DG.Alias } $RemoteMembership=(Invoke-Command @parameters) but I got the following error The syntax is not supported by this runspace. This can occur if the runspace is in no-language mode. + CategoryInfo : ParserError: ({(Get-Distribut...rySmtpAddress }:String) [], ParseException + FullyQualifiedErrorId : ScriptsNotAllowed Running the command (Get-DistributionGroup distributiongroup | Get-DistributionGroupMember).PrimarySmtpAddress locally on the remote exchange server obviously works Is there a way I can do it ? thanksSolvedStefanoC66Nov 29, 2024Brass Contributor34Views0likes1CommentExport/Import distribution group members
We're migrating from one forest to another and among other things we have to migrate memberships of distribution groups betweene the two. The problem arised because many distribution groups in the source forest contains "contacts" as members. Since we're using ADMT, which does not migrate contacts, to do the migrations we have exported/imported contacts to the target forest. Now when we migrate the distribution groups they lack the contacts in the membership so we thought of a way to read the distribution group membership from the source domain and update them in the target domain but couldn't manage to get the script working. How can we remotely run the script to extract the group memebership from source domain and add them in the corresponding groups in the target domainStefanoC66Nov 29, 2024Brass Contributor31Views0likes1CommentHow to remove shared link from subfolder in sharepoint online?
I tried out remove shared link from subfolder by powershell in sharepoint online: Remove-PnPFolderSharingLink -Folder "/sites/site/subfolder/" -Identity 52 But I get error: Remove-PnPFolderSharingLink: Exception of type 'System.Management.Automation.PSInvalidOperationException' was thrown. And "Get-PnPException" shows: Message : Exception of type 'System.Management.Automation.PSInvalidOperationException' was thrown. Stacktrace : at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 101 at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 121 at System.Management.Automation.CommandProcessor.ProcessRecord() ScriptLineNumber : 1 Is there a way to remove shared link from subfolder with powershell in sharepoint online?Mark346121095Nov 29, 2024Brass Contributor6Views0likes0CommentsMicrosoft Graph Sign in Log Script
Hi all, I'm trying to create a script that will check sign ins based on the location. How ever the location always appears as 'Microsoft.Graph.PowerShell.Models.MicrosoftGraphSignInLocation'. I am able to see the location if I select the property 'location' by itself and expand the property, but then that only show's a list of the locations. If I add other properties, it either doesn't work or it displays like this: I tried exporting as a csv and the location column values showed up as 'Microsoft.Graph.PowerShell.Models.MicrosoftGraphSignInLocation'. This is what I have currently: Get-MgAuditLogSignIn -Filter "location/countryOrRegion eq 'AU'" -Top 10 | format-list And if I try selecting properties (I would add more properties later, this is just an example: $properties = 'location, userprincipalname' Get-MgAuditLogSignIn -All -Filter "location/countryOrRegion eq 'AU'" -Top 10 -Property $properties | Select -ExpandProperty $properties Has anyone tried something similar?zacNov 29, 2024Copper Contributor15Views0likes0CommentsHow does Defender work with other AV
Another thing I ran across that would like some explanation. Tested on both Win10/11. With both Avast and Defender checking AV with powershell Product GUID : {D68DDC3A-831F-4fae-9E44-DA132C1ACF46} Name : Windows Defender Real-time Protection Status : Enabled Computername : [ME] Product Executable : windowsdefender:// Reporting Exe : %ProgramFiles%\Windows Defender\MsMpeng.exe Definition Status : Up to date Product GUID : {EB19B86E-3998-C706-90EF-92B41EB091AF} Name : Avast Antivirus Real-time Protection Status : Enabled Computername : [ME] Product Executable : C:\Program Files\Avast Software\Avast\wsc_proxy.exe Reporting Exe : C:\Program Files\Avast Software\Avast\wsc_proxy.exe Definition Status : Up to date and if Defender is set up to scan on occasion shows up as enabled #when running # Get-MpComputerStatus AMEngineVersion : 1.1.24090.11 AMProductVersion : 4.18.24090.11 AMRunningMode : SxS Passive Mode AMServiceEnabled : True AMServiceVersion : 4.18.24090.11 AntispywareEnabled : True AntispywareSignatureAge : 21 AntispywareSignatureLastUpdated : 11/6/2024 5:05:45 AM AntispywareSignatureVersion : 1.421.135.0 AntivirusEnabled : True ...... more properties follow but not relevant here but when I try to update, get error #Update-MpSignature Update-MpSignature : Virus and spyware definitions update was completed with errors. At C:\PSFiles\AV\Defender.ps1:3 char:1 + Update-MpSignature + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (MSFT_MpSignature:ROOT\Microsoft\...SFT_MpSignature) [Update-MpSignature], CimException + FullyQualifiedErrorId : HRESULT 0x80070652,Update-MpSignature Is this an issue with Cim vs WMI?StanLNov 27, 2024Copper Contributor10Views0likes0Commentspowershell on mac
Hello Everyone, I’m new to using PowerShell on a Mac. I was given a PS1 script that needs to be run on a Mac device to check the files and folders of logged-in users. I managed to achieve this to some extent, but now I’m stuck on granting full disk access to the PWSH app via a Jamf Pro privacy payload. Since the PWSH app is not a signed package, I was unable to identify the “code requirements” to add a payload in Jamf Pro. Could you please share your best practices for deploying PowerShell and granting it full disk access via Jamf Pro?Shamir_MohammedNov 26, 2024Copper Contributor27Views0likes0CommentsNot able to export AD attribute departmentnumber
Hi, I'm trying to generate a report for all AD users with some AD attributes, such as SamAcconutName, department, departmentnumber, etc. The report is fine with all except departmentnumber. it shows "Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" instead of actual number. Here is my PS cmdlet. get-aduser -Properties * | select displayname, departmentnumber | Export-Csv c:\temp\users.csv -NoTypeInformation When tested against a single AD account using the same cmdlet, the screen output shows the value with { }, for example, {123456} instead of 123456. employeenumber attribute worked fine. The same cmdlet shows just the number. Please help, How can I query and export attribute departmentnumber in a report properly? Thanks, Davedding0919Nov 21, 2024Copper Contributor67Views0likes4CommentsPowershell 7 getting error updating multi-valued attribute using Set-ADUser. PS 5.1 works
Hi there, I recently moved to PS 7.4 since there is some additional commands related to parallel threads. Now I'm facing an unexpected error due to multivalued updates using Arrays. It says "Invalid type 'System.Collections.ArrayList'" using the following command (that works in previous PS versions): Set-ADUser -identity "user" -Replace @{uid=@("value1","value2")} Already tried many options, like using variable, explicit array declaration and followed Copilot suggestions, but no success yet. It seems like a bug for me. Does anybody knows how to overcome this issue?mmussoliniNov 19, 2024Copper Contributor45Views0likes3Comments