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
3 votes
0 answers
2k views

Missing WSMan provider on PowerShell Linux (to use remoting)

I'm trying to remote PowerShell from Linux to a Windows Nano Server on Azure. There's a part in the instructions where I add the IP of the remote server to local computer's trusted hosts: PS > ...
3 votes
1 answer
13k views

Powershell remoting with active directory

I am able to connect to domain controller via below scrip remotely, but after that i want to run disable-ADAccount ,Get-ADUser command but I am getting error Get-ADUser : The server has rejected the ...
2 votes
1 answer
8k views

GPO for PS1 logon script does not work without local admin rights for user

I have a PowerShell .PS1 script that I am trying to get to apply via a logon script with Group Policy. Here is the .PS1 script (very simple, just adds the user to RD Users group): net localgroup "...
4 votes
3 answers
8k views

Removing Windows 10 Built In Apps from a Windows 10 Image

I've Googled all over the place on how to remove the built in Windows 10 Apps like 3D Builder, Zune, Xbox, etc from a Windows 10 image file. All of the tutorials always point to the same thing - ...
1 vote
2 answers
1k views

Pushing a hosted Registry File to Multiple Servers

I have bunch of Servers I need to push this patch through. Normally I would load up a WSUS or equivalent. However I would like to get this working in a DSC enviroment. So I am testing scripts to put ...
0 votes
1 answer
1k views

Get all AD users not in parent group

I have a group that I use named staff. It is a parent of a few nested groups. I need to audit the group to list the users who aren't a part of that group or any nested child groups within it. I ...
3 votes
1 answer
4k views

Look up where a NTFS group is used

We are doing some AD clean up and migrating or deleting old AD groups and replacing them with our current naming stranded in AD. The challenge that we are running into is making sure we have the we ...
8 votes
2 answers
6k views

Determine if PowerShell script has been run from the desktop or command line [closed]

Windows Explorer (desktop) has the ability to run a PowerShell script by right-clicking and selecting "Run with PowerShell". However, as the window is closed when the script has finished, any messages ...
3 votes
1 answer
1k views

robocopy wierd behavior for /copyall

When I use robocopy with /copyall flag, the 1st attempt for the files will be display as "New Files" and the output will display the number of new files copied and other transfer/bytes information. ...
2 votes
1 answer
644 views

Nano Server - Move Pagefile

Update: I never found a way to move the pagefile and with Microsoft's pivot to make Nano container only I doubt there will ever be a way to do this. I am trying to move the pagefile on a Windows ...
1 vote
1 answer
1k views

Full non-interactive start + connect to VM from PowerShell

I know how to connect to Hyper-V VMs from CLI: vmconnect localhost 'machine' I also know how to start them non-interactively, I do this via shortcut like this: powershell.exe -ExecutionPolicy ...
5 votes
3 answers
50k views

Close locked file in Windows Share using Powershell and Openfiles

I work with a lot of folder shares, but there are a bunch of locked files which have been opened by some other process. I need to close those files. So far I've been using MMC - System Tools - Shared ...
0 votes
1 answer
30 views

retrieve roles or parameters from Domain and trusted domains

I want to retrieve the information about those installed roles and its parameters (if possible ) from Domain Server and trusted domains NOT current computer I'm running on with cmdlets, powershell. ...
1 vote
2 answers
10k views

Powershell - Split Array Value keep first element

I'm trying to extract just the IPs from a filtered JSON using the following code: $curl = Invoke-WebRequest -Method Get -Uri "http://urltojson.com/file.json" $curl2 = $curl.Content.replace(&...
2 votes
2 answers
3k views

Lookup ip geolocation via command line

I've been trying to piece together a quick and dirty script to return the geolocation of a bunch of IP addresses. I'm using freegeoip.net and couldn't find a quick wget equivalent for cmd line so ...
1 vote
2 answers
1k views

Move workstations from one OU to another

I have pieced together the below powershell script but when i run it on my DC i get the below error message. My overall goal is to have the script pick up on any workstations within the Computers OU ...
0 votes
1 answer
676 views

Powershell yields different results when run from Task Scheduler

I have a simple powershell script that runs fine when I execute it from the powershell editor, but yields entirely different results when I run it from Windows Task Scheduler. Original code is below ....
0 votes
1 answer
8k views

LAPS PS module fails to import

On a Windows Small Business Server 2011 Essentials server, elevated PowerShell command Import-Module AdmPwd.PS failed and outputted the following: Import-Module : Could not load file or assembly '...
0 votes
1 answer
2k views

Windows 10 Hibernate Boot let's suspend (Powershell) Script execution at Startup

I am intensively working with Powershell Scripts which are executed at startup (local machine, not logon). I had some problems to troubleshoot like "Wait for network" or replication failures between ...
1 vote
1 answer
140 views

Adding user to azure windows server 2016 with powershell access

I have added a user to the azure vm and added the user to the "Remote Desktop Users" group, they can access the server using rdp but not via powershell like the main user. How can I allow the user to ...
0 votes
1 answer
141 views

Export object location from CSV

I need to export the object location of servers from a list. I have tried using the following script, but it only checks the mentioned OU, how can I search the entire domain and export the canonical ...
20 votes
3 answers
20k views

How do I delete this orphaned Active Directory computer object (preferably with PowerShell)?

I'm working from a Windows 7 workstation, with PowerShell v2.0, and trying to delete a particular (orphaned?) object from the LostAndFound container in a 2008 R2 FL forest and domain with the Active ...
0 votes
1 answer
3k views

PowerShell fails trying to get content from a shared folder from a remote computer

We are using the following software: PowerShell v1 Windows 7 Professional When I run the following on a remote computer in PowerShell all works correctly:(the files from the shared folder are shown)...
1 vote
1 answer
219 views

Azure DSC validation error on portal

Any ideas on the cause value for the template parameter 'modulesUrl' at line '11' and column '20' is not provided returned when validating a new VM in the Azure Portal with the DSC extension. It's no ...
1 vote
1 answer
1k views

PowerShell DSC fails to create application pool with xWebAdminstration

At the moment we are trying to setup an application pool using PowerShell DSC (WMF5.0) and the xWebAdminstration (v1.15) module. We have, so far, managed to get the client node and pull server to work ...
1 vote
2 answers
808 views

How to see what IIS config elements are changed from default?

On Windows Server 2012, 2012-R2 and 2016 (e.g. IIS v8.0 and up) We have an IIS setup, that has evolved over the years. How do I extract its "delta to default IIS" so we can make a script to set up ...
2 votes
1 answer
427 views

Truncating part of an LDAP DN in Powershell? (Or getting the OU from an LDAP DN.)

What's the easiest way to get the OU containing an LDAP object in PowerShell? I'm working on a script to manage some groups that I've made "dynamic" with a script, and I can get the full ...
0 votes
1 answer
57 views

automatically logoff interactive user sessions for workgroup windows servers

I have windows application servers that are not domain joined and any changes I make to them must be doable via a locally run script (not a remote command) that is executed when they are provisioned ...
3 votes
2 answers
7k views

Access Denied Importing Certificate on Remote Machine

I'm trying to come up with a way to push out a certificate for install on multiple machines. The method I came up with is: Invoke-Command ServerName {Import-Certificate -FilePath "path" ` ...
1 vote
1 answer
15k views

Office 365 Powershell - Export user to csv file

I took this script from that post : Office 365 Powershell but when I run it, I receive that error : WARNING: More results are available. Please specify one of the All or MaxResults parameters. ...
0 votes
1 answer
4k views

Powershell - add to array without echoing index

I'm adding items to an array called $MissingIps using the following command $MissingIps = @("") [System.Collections.ArrayList]$ExistingIps = $MissingIps if ($lbips -notcontains $awsip){ ...
0 votes
3 answers
5k views

Unable to remove publicfolder replicas on exchange 2007

I try to decommissioning my Exchange 2007 server after migration to Exchange 2013, to migrate to 2016 in the future. I removed all mailbox databases, but not the publicfolder database, i got an error ...
0 votes
1 answer
675 views

Using PowerShell Resize-Partition on RAID 1 Volume

Can I use the PowerShell command Resize-Partition within a RAID 1 volume to move space between two partitions (the size of the volume itself is not changing) without any adverse side effects? If not, ...
2 votes
1 answer
1k views

Powershell: set Registrykey owner to SYSTEM user

I have to add an exclusions path to Windows Defender registry key. I am aware that there are Cmdlets provided from Windows Defender to use them directly for these kinds of purposes. But unfortunately, ...
1 vote
1 answer
5k views

Powershell Script to export directory folders and owners (excluding files)

I am trying to export all folders including child folders within a file share on a remote server alongside the owner info as shown (Note I do not need info re the files within the folders) get-...
0 votes
1 answer
3k views

Get-Migrationbatch - Return specific job with status

I've created a PowerShell script that creates a migration batch from Exchange on-premises to O365 Exchange Online using the New-MigrationBatch cmdlet. My next step is to halt the script until the the ...
2 votes
2 answers
6k views

Windows: Find out which process spawned another process

I have a situation with processes a bit like below. We have 2 executables, foo.exe and bar.exe. bar.exe is always launched by foo.exe. I want to know how to find out which bar.exe has been spawned by ...
1 vote
3 answers
3k views

PSSession as logged in user

I'm trying to setup a Powershell script that will monitor a VirtualBox VM (i.e, "Builder4") running on one of our build servers. It occasionally loses connection and I already have a script (local on ...
1 vote
0 answers
735 views

TaskScheduler trigger on specific task

I have a backup service running through TaskScheduler. The backup task runs a batch-file which does all the magic. Sometimes the backup fails which fills a log table until the server becomes ...
0 votes
0 answers
222 views

Windows Server 2012 R2 fails to load Remote Desktop module in powershell

I have my citrix master image that i'm using to test a script meant for a staggered reboot for my target devices. Need to import remote desktop module for the script to work. For some reason i cant ...
0 votes
1 answer
223 views

Cloudberry powershell

I am trying to automate the upload of files to Glacier using Cloudberry Explorer's PowerShell snapin but cannot seem to copy files to my preferred destination. For some reason, the source directory ...
0 votes
2 answers
2k views

How to expand this property in PowerShell

I'm trying to expand Members property in powershell whithout success :( Here is my code... Import-Module ActiveDirectory Get-ADGroup -Filter * -Properties * | Select-Object -Property Name, ...
1 vote
1 answer
1k views

How to edit "path" and "ConfigurationLocation" of a VM in Hyper-V 2012 R2

I need to make some changes to a Hyper-V storage and I need to modify certain settings of each VM on the host. The values I need to change are: ConfigurationLocation SnapshotFileLocation ...
2 votes
2 answers
1k views

Last known computer login

I have been using the following command to output the last known login of a list of computers set for decommissioning. The script works but only on the currently logged on DC. How can I get it to ...
0 votes
1 answer
2k views

How to add a service account (sp_c2wts) to local security policy using powershell?

Is there a powershell way to achieve this? I have to do this for 40 servers. Set the following permissions on all SharePoint servers in the farm (All must be done) – this is completed under Local ...
0 votes
1 answer
211 views

How can I create a file screen for each path in this variable?

I have a script that scans a server for drives that contains shares. After that I need it to create a file screen from a template that is already created with the same script, that part works fine. ...
15 votes
5 answers
243k views

List All Groups and Their Members with PowerShell on Win2008r2

I am new to powershell, but I've been reading manuals and practiced a little bit. My objective is to List all users in all Security Groups under specified path. I have found the way to do it: get-...
0 votes
1 answer
616 views

Troubleshooting a Powershell script that sends email

This script is sending an email when a particular event is triggered. I am running this script when a file screen i have configured on FSRM detects a user saving specific file types. The command tab ...
1 vote
1 answer
117 views

Windows Server: restrict user file operations per minute

I would like to restrict my AD users so they can only modify/create let say 10 files per minute via samba share. I think it can help to reduce destructive effects of ransomware activity. Is it ...
3 votes
2 answers
3k views

List users recursively in large organization AD

I have a script that recursively lists group members. The issue is that there are over 5K so I cannot use Get-ADGroupMember, and I also need to only get enabled users. UAC, despite microsoft ...

1
37 38
39
40 41
83