Questions tagged [powershell]

An interactive shell, scripting and programming language, and surrounding environment from Microsoft. Commonly used by system administrators managing Microsoft software (including Windows, Exchange, SharePoint, and cloud services Azure and Office 365), PowerShell is included by default with Windows, and takes over from previous languages such as VB Script.

Filter by
Sorted by
Tagged with
0 votes
0 answers
23 views

Cmdlet Get-ADGroupMember only working on domain controller but not on other servers when FSPs are included

we have an AD forest with two domains: company.com test.company.com We have replaced the domain controllers for test.company.com (OS changed from W2012R2 to W2022, but not as in place upgrade). ...
user avatar
0 votes
0 answers
27 views

How to check elevated priv of normal user?

Hi guys, Is there a way to check all privileges of current user when elevated by using command only? (user does not belong to group administrator) As you can see in the image above, when I open cmd ...
user avatar
0 votes
0 answers
16 views

Use SCCM Reports as variables in PowerShell

I need a way to get SCCM Reports via PowerShell. The intention is to play, manipulate, analyze etc. with the reports. that's why the reports needed as variables. I remember that 8 months ago I've did ...
user avatar
0 votes
0 answers
17 views

How to install Windows Updates from command line without third party scripts

I am aware of PSWindowsUpdate but this is a third party script that is not created by Microsoft. For the more security conscious of us out there, I am wondering how to install all available Windows ...
user avatar
  • 328
0 votes
0 answers
14 views

Create a route that will persist between reboots with New-NetRoute?

I am trying to use Powershell to create a route that will persist between reboots. We've noticed that although it appears in the Persistent Routes: section of the route print command that it doesn't ...
user avatar
  • 4,787
0 votes
0 answers
10 views

Powershell to remove EC2 snapshots

Below is a snippet to print the snapshot ids that are grabbed below a certain date. I can see that the text file is created with the older snapshot details like the below, but snapshot ids are not ...
user avatar
0 votes
0 answers
43 views

"The directory name is invalid." when trying to run PowerShell startup scripts

I have a GPO startup script that creates a text file in C:\Windows\Temp: Set-Content C:\Windows\Temp\GPOtest.txt -Value "$(Get-Date)" Obviously, the final script will do something more ...
user avatar
  • 415
0 votes
1 answer
46 views

Microsoft Storage Powershell Module 'Get-Disk' doesn't list disks when Failover-Clustering is installed

I have 10 disks on a Windows 2016 Server. If I have the Windows feature 'Failover-Clustering' installed, the Get-Disk cmdlet only reflects two disks - even when the server is not yet part of a ...
user avatar
  • 123
0 votes
1 answer
29 views

Powershell way of doing redircmp and redirusr

I've used redircmp and redirusr for as long as I can remember to change the location for new user and computer accounts in a domain. It has worked flawlessly time and time again. However, I am doing ...
user avatar
  • 303
0 votes
1 answer
25 views

Powershell - Get-ADOBJECCT Trying to show a subset of values of a custom class

Here is my script that works great: Select-object -Property name,@{Name="bofaamlmember";Expression={$_.bofaamlmember -join ";"}},@{Name="canonicalName";Expression={$_....
user avatar
0 votes
0 answers
14 views

PowerShell waiting for dialog to load

I have a set of PowerShell scripts that simulate keypresses (using [System.Windows.Forms.SendKeys]::SendWait() to trigger actions in a GUI application. No-one likes this process, but there is no other ...
user avatar
  • 133
0 votes
1 answer
24 views

What do the parameters of Set-VPNConnectionIPSecConfiguration Mean

The only way to manually configure what encryption proposals windows provides for an IPSec VPN connection seems to be through the PowerShell command Set-VPNConnectionIPSecConfiguration. However, the ...
user avatar
  • 103
1 vote
0 answers
22 views

Managing WSUS with Powershell. How to remove an automatic approval rule?

I'm writing Powershell scripts to manage WSUS. One script can create, read, and update automatic approval rules. But it can't delete rules. WSUS allows admins to make rules with duplicate names. If ...
user avatar
0 votes
0 answers
25 views

Create a New-PSDrive with username and a blank password

I have disabled the blank password restriction in the group policy. I'm unable to create a PS-Drive without the password with just code and no user inputs. $user = "Admin" $creds = New-...
user avatar
0 votes
1 answer
39 views

How to install DFSN module in powershell?

I have two machines, one has DFSN available (functions like Get-DfsnFolderTarget, etc) and the other doesn't. I can't seem to find any information online about installing it, and I'm not a powershell ...
user avatar
0 votes
1 answer
50 views

PowerShell, Active Directory Get-object issue

I have been tasked to create a list of members of a custom object/custom attribute in Active Directory. I felt the best way to do so is use PowerShell. I can list the objects in a specific OU, but I ...
user avatar
1 vote
1 answer
18 views

Creating Zip Using Foreach in PS Produces Nothing

I have a little use case where I need to zip each directory within a directory (the subdirs are flat, so no worry about recursion) and attempting to do so with a simple one liner in PS has produced ...
user avatar
0 votes
1 answer
21 views

Windows 10 Offline files synchronization monitoring

There is a class in WMI ROOT\CIMV2 named Win32_OfflineFilesHealth with property LastSuccessfulSyncTime. But the class is having no instances even if I have Offline files enabled and I'm using it. What ...
user avatar
1 vote
1 answer
36 views

Why is the GroupPolicy module not found even when RSAT is installed?

I'm trying to use the Get-GPO PowerShell module. So I installed RSAT first, but the GroupPolicy module is still missing: PS C:\Users\admin\Desktop> Install-WindowsFeature RSAT Success Restart ...
user avatar
  • 737
2 votes
3 answers
191 views

Why does a scheduled task access the database as anonymous (vs configured acct)?

**Update: I added a much shortened script which generates the same issue. See the bottom of this port: I have a PowerShell script that runs a SQL query against a MSSQL server (different server). The ...
user avatar
  • 6,317
0 votes
0 answers
23 views

Is this powershell script appropriately using the Get-ADUser command to filter with a txt file?

Here is the command I have so far. $List = Get-Content c:\userlist.txt $Users = @() foreach ($Item in $List) { $Users += Get-ADUser -Filter {samAccountName -like "*$Item*"} } $Users | ...
user avatar
-3 votes
1 answer
37 views

Is it possible to take a list of usernames and search for and export specific Active Directory information?

so I have a list of about 1100 usernames in AD and I was wondering if someone could point me towards a powershell command to use the list of usernames to get Client IP Addresses, Client Host Names, ...
user avatar
-3 votes
1 answer
22 views

Need help creating a powershell script to update microsoft edge in Azure WVD enviroment (VM's )

OS : Windows 2019 Server Requirement steps: 1 - close all sessions in the WVD VM. 2 - launch Edge and open the About page 3 - close edge after a couple of mins and then update it a lot of time ...
user avatar
1 vote
1 answer
44 views

Powershell showing only 0 values for available cipher suite

I have multiple VMs within the azure cloud. All of them, except one, are unable to connect to certain services using SSL with the message Invoke-Webrequest : The request was aborted: Could not create ...
user avatar
  • 21
0 votes
0 answers
16 views

Configuration Manager cmdlets fail to run as System account. "Value cannot be null. Parameter name: key"

I came up with a nice PowerShell script to manage our monthly maintenance windows in Configuration Manager based on MS Patch Tuesday + Offset. Create, Update and Clean up options. The script works ...
user avatar
0 votes
0 answers
26 views

Can we publish software through GPO using powershell?

I have created and linked GPO's throggh powershell now i just want to create a software package in GPO -> Computer Configuration -> Policies -> Software Settings using powershell. I know that ...
user avatar
  • 151
0 votes
1 answer
25 views

How to Sum output of a Powershell command

i have written a one-liner to sum up the space of all Exchange Mailboxes. It's like [PS] C:\Windows\system32>Get-Mailbox | where {$_.RecipientType -eq "UserMailBox"} | Get-...
user avatar
  • 113
1 vote
1 answer
47 views

How to Delete CRL Files in Local Cert Store

I need to import CRL files to a Bastion server that is not part of my environments domain. The CRL files are updated every few days so a new copy needs to be imported to the local cert store on the ...
user avatar
  • 598
0 votes
0 answers
16 views

Retrieve total bytes sent/received though Hyper-V virtual network adapter with Get-CimInstance

I'm using the following Get-Counter command in a powershell to retrieve total bytes sent/received through a specific virtual network adapter of a virtual machine running in Hyper-V: Get-Counter -...
user avatar
0 votes
0 answers
25 views

Powershell Graph API: Cannot use AND within $search

I don't seem to be able to use AND in $search. Below just returns everything in the mailbox. What did I do wrong? $api = 'https://graph.microsoft.com/V1.0/users/john.doe@domain.com.au/messages?$search=...
user avatar
0 votes
0 answers
28 views

Retrieve Win32_UserAccount object by its full (not "pre-Windows 2000") logon name

I'm attempting to look up the SID for a specific user account in a PowerShell script. Prior research suggests that this can be done using the Get-CimInstance command, like so: # This doesn't work for ...
user avatar
  • 167
-1 votes
1 answer
27 views

Office 365 and powershell: is there a way to get the list of devices where the user has signed in

Since we're already in 2022, I'm wondering if there's a Powershell solution for getting a list of devices where the user has installed/activated office 365.The only references I've found seem to ...
user avatar
0 votes
0 answers
10 views

Cannot set credentials with New-Service; have to use sc.exe config – why?

I'm working on a PowerShell script that's … creating a local user adding that user to the "Log-in as Service" policy creating a new service that's supposed to run as the user that's been ...
user avatar
  • 101
1 vote
1 answer
42 views

Powershell script credentials prompt appears before read-host executes

I'm calling a script inside another script: ... ... powershell C:/temp/script2.ps1" ... ... That joins a VM to a domain after downloading some things. However, when the script runs, the prompt ...
user avatar
0 votes
1 answer
82 views

Retrieving Active Directory Users with no Email address from a certain group in powershell

I'm trying in powershell to output all AD users from a certain group with no data in the email address field. I have the following command: get-aduser -filter * -properties * | where {!$_.emailaddress}...
user avatar
0 votes
0 answers
9 views

How to filter and save only userName and password from publishMethod:msDeploy as variable for powershell

I have run the following command and it returned the following as output. I need to only select the userName and userPWD to be used in a ps script. Command used: Get-AzureRMWebAppPublishingProfile -...
user avatar
0 votes
0 answers
15 views

AMI import via Import-EC2Image fails when attempting to use EBS disk encryption

I'm trying to import an OVA to EC2 as an AMI using the AWS.Tools module for PowerShell 5.1 and a pre-existing KMS disk encryption key we've used on other Instances and AMIs, but if I un-comment the ...
user avatar
  • 1
4 votes
1 answer
373 views

Is there a way to programatically determine whether a Windows computer is AAD joined as SYSTEM?

I would like to be able to determine via script whether a given Windows workstation is AAD joined, Hybrid AD joined, or on-prem AD joined. I would like to run this script from the RMM I'm using so I ...
user avatar
0 votes
1 answer
181 views

Search Active Directory by Canonical Name

The Manager field for contacts stored in Active Directory holds the CanonicalName of the manager's AD object, not the username or DistinguishedName. I need to be able to search AD for the manager of a ...
user avatar
0 votes
0 answers
22 views

Windows server manager got uninstalled after deactivating windows power shell ISE (Windows server 2016)

After removing Windows Powershell ISE feature, the server manager became unavailable until reenabling/activating Powershell ISE. any help on how to remove it without affecting server manager.enter ...
user avatar
0 votes
0 answers
47 views

run task in the background

i have powershell script that check if the service is up and of not it starts it up, $ServiceName = 'mapguideserver3.1' $arrService = Get-Service -Name $ServiceName while ($arrService.Status -ne '...
user avatar
0 votes
2 answers
717 views

Run a PowerShell script once on all computers as admin via GPO without changing execution policy

I have a PowerShell script that I need to run once on all computers in my Active Directory domain. A large number of computers are off at any given time, so a GPO would allow us to ensure that it ...
user avatar
  • 1
0 votes
1 answer
35 views

Need help in Moving files to the backup directory except the last 10 files based on file NAME not date modified

I have a situation where a server is creating journal files (MJ00001-MJ000x) and I want to move all the files to a backup directory but need to keep the last 10 in there to get the archive. I looked ...
user avatar
  • 3
0 votes
1 answer
17 views

Globing patterns

How can I make a command string work using globing patterns also in the given arguments? powershell.exe -c "&'c:\wind?ws\System32\more.com' C:\path\to\something.txt | findstr 'something'"...
user avatar
  • 3
1 vote
0 answers
37 views

Change Windows Store Apps language using poweshell or unattend.xml?

I am trying to create a golden image and I can't find any way to set Store Apps language. These are the settings I want: Windows Display: English (US) Apps & Websites: English (US) Regional Format:...
user avatar
  • 11
0 votes
1 answer
67 views

How is ExchangeOnlineManagement PowerShell module related to ExchangePowerShell module?

Please let me understand how ExchangeOnlineManagement and ExchangePowerShell modules are related each other. For example Microsoft Docs describe cmdlet Connect-ExchangeOnline as it comes from ...
user avatar
  • 141
0 votes
0 answers
32 views

Powershell Remoting with local Administrator in Domain

I would like to establish Powershell remote sessions to domain members by using their local administrator for authentication. Let's say I have a host called "server1" in the domain "...
user avatar
0 votes
0 answers
329 views

PowerShell - List WSUS Updates Needed for Each Client

I need to provide a monthly report to our client listing the updates needed by each Windows server in our environment. Ideally, the report would list the updates for the month and the servers in my ...
user avatar
  • 598
0 votes
0 answers
487 views

Invoke-RestMethod : The remote server returned an error: (400) Bad Request for PATCH request

I am working on stale device cleanup script to perform cleanup of stale devices from Azure AD tenant. I am also using graphAPI to retrieve device information Via GET request which works fine. But when ...
user avatar
-2 votes
1 answer
20 views

How to change IP address of azure NIC, as soon as azure load-balancer's health probe detect instance unhealthy?

I have two machines in backendpool of azure LB, I would like to update network interface usign rest api as soon as health probe detects vm is unhealthy. is there any way to to recoginse that event ...
user avatar

1
2 3 4 5
80