active direcory
2 TopicsRemote 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 ? thanksSolved64Views0likes1CommentHow Do I - Run a PS Script automatically when Insert USB drive to verify credentials, start program?
I want to have a PowerShell script that runs automatically when I insert a USB drive. Here's exactly what I want to see happen: Step 1. -- Insert USB Step 2. -- A script runs automatically that pops up a window requesting I enter my credentials Step 3. -- Those credentials are verified against Active Directory Step 4. -- If the credentials are good, then a program is executed (let's say outlook.exe) Step 5. -- If the credentials are bad, it prompts me a maximum of 3 times before NOT running the program and displaying a bad credentials message or something to that effect. Info: The program (outlook or anything), PowerShell, and the script will all be on the USB drive. Please forgive me if something like this is already posted but I did a search and couldn't find exactly what I was looking for. Any help would be greatly appreciated and I promise to contribute when I become good at this. Thanks.5.2KViews0likes0Comments