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
1 vote
1 answer
11k views

Set-msoluser: why "Access Denied"?

I have an Azure account with a user "rmuser" that I've created specifically for automated shutdowns of VMs. That user's password expired so VMs stopped being shut down. I've manually changed the ...
0 votes
1 answer
2k views

How to get a signed powershell script on Windows without deprecated makecert.exe? [closed]

I've followed the instructions here Create Code Signing Certificate on Windows for signing PowerShell scripts but it doesn't work as I get this error: File C:\temp\script.ps1 cannot be loaded. A ...
0 votes
1 answer
2k views

Get-MailboxExportRequest not returning any results

I have created a mailbox export request on my Exchange 2016 environment to export a user's mailbox to a PST. I am trying to run Get-MailboxExportRequest to see what the status of the export is. ...
0 votes
0 answers
36 views

Programatic Registry editing blocked

I am seeing a situation where a PowerShell script can't write to the Software key of the Local Machine hive, but the user can manually do it in Regedit. Is there a Group Policy that would limit ...
0 votes
1 answer
11k views

Powershell send-mail message, how to put line break in body variable

I am searching for a string in multiple files within a folder. If I get that string, then I would like to email all these folders which have this string. I have figured all that out and have adjusted ...
1 vote
1 answer
2k views

Retrieve "same as parent folder" A record using Get-DnsServerResourceRecord

I am trying to retrieve a single A Record from a zone. Here's the Powershell command I am using(showing only relevant columns) Get-DnsServerResourceRecord -zonename search.contoso.com -computername g-...
1 vote
0 answers
447 views

Compress traffic when copying a lot of files over network between two Windows server?

The tools under unix/linux, e.g., scp, rsync, etc., support compression when copying files. Does any Windows (Server) tools do the compression when copying? I will need to copy 5TB of text files ...
0 votes
0 answers
886 views

Run powershell queries against SCCM reports

My company is using SCCM. I have run access to one of the default reports called "Monitoring\Overview\Reporting\Reports\Network\MAC - Computers for a specific MAC address". It returns all computer ...
4 votes
3 answers
6k views

How to get AD user's "Display name" instead of logon name (domain\userid) while exporting "send as" and "full" permissions?

I have googled and created two scripts . (1), (2) (1)First one is to export "Full Access" of a shared email box called "ap.cz" Get-Mailbox ap.cz | Get-MailboxPermission | where {$_.user.tostring() -...
5 votes
2 answers
427 views

how to use powershell object properties directly without typecasting and spliting?

I have created a small script to transfer value of Active directory pc attribute called pssfulllocation from one pc to anoter pc.. To achieve this I have to use typecasting + splitting.. Here is ...
3 votes
1 answer
5k views

Windows 2012R2 How to disable "Use root hints if no forwarders are available" using a powershell command

I'm setting up an automatic infrastructure orchestration of Windows 2012R2 machines using Ansible. I am creating domain controllers and DNS machines (resolvers, root servers and authoritative name ...
0 votes
1 answer
622 views

Change MS SQL Server database size from Powershell

I need to use Powershell to automate changing the size of a database on an MS SQL 2014 instance. Currently, we perform the following manual steps. Open SQL Server Management Studio Connect to ...
11 votes
2 answers
145k views

Powershell: A parameter cannot be found that matches

I am new to the Powershell world. Below is my first script $sServer = "Fully.Qualified.Computer.Name" $os = Get-WmiObject -class Win32_OperatingSystem -computername $sServer $object = New-Object –...
5 votes
1 answer
1k views

Why can't I use a DSC resource in push mode from a module that is installed in my user's module path?

I have a Powershell DSC custom resource, embedded in a module. The full code is available here if you want to see it, but that may not be necessary; my problem isn't (I think) in the code I wrote, but ...
3 votes
2 answers
11k views

Powershell get-aduser not showing all results

I'm trying to pull some data from AD but am getting some confusing results. I'm running: Get-ADUser -Filter * -Properties * | select userPrincipalName, msTSLSProperty01 and it presents me with all ...
0 votes
1 answer
4k views

Port needed to join to Domain throw Powershell

i need to join PCs with public and domestic firewall profiles activated. If i shutdown both firewalls profile in target Host the following command works fine. Add-Computer -ComputerName $targetHost-...
2 votes
1 answer
3k views

IIS Application Request Routing(Monitoring and management) Powershell

I am working with iis arr powershell... In my iis i have one web farm and in that i have two servers "server1" & "server2"...... My task is Make server1 unavailable gracefully restart server1 ...
0 votes
1 answer
770 views

Powershell function returned value changes when I start a PSSession inside

I'm trying to write a simple function that returns $true when a mailbox exists on my Exchange server and $false when it does not exist. The function itself starts the PSSesssion to the Exchange server:...
3 votes
2 answers
8k views

How to hide command window at while running powershell script through the task scheduler?

I have powershell script with GUI form which show message by condition. This script is runnig through the task scheduler every 15 minutes. Every running shows me concole window, then GUI form with ...
2 votes
3 answers
8k views

Powershell Start-process -Argument list not working

Start-Transcript c:\scripts\InstallUpdates.log -Append # -NoClobber $SourceMSUFiles = (get-content install-list.txt | where {$_ -like "*.msu"}) #Install MSU files foreach($file in $SourceMSUFiles) { ...
2 votes
1 answer
7k views

Display Hyper-V vSwitch configuration in Powershell

Is there a way to display the full settings of a specific Hyper-V vSwitch using Powershell? I'm trying to configure port-mirroring from the vSwitch to the Destination vNIC on a VM and so I've set the ...
12 votes
1 answer
108 views

How to use powershell to administer Hyper-v Cluser

I have 2 hosts both with Server 2016 Datacenter On each host I have 2 VM's currently Dev using shared storage I can do all the cluster things ie., Live migrate, move storage, I have been looking ...
13 votes
1 answer
189 views

Configure Hyper-V VM powershell

How can i reconfigure Hyper-V VM's I want to be able to change the VM configuration file, check points, and virtual hard drive locations with Powershell. My Google-FU is only pointing me at moving, ...
0 votes
1 answer
393 views

Creating an output to powershell from an ini while matching if it exists then skip

I am trying to pull data from a .ini file using the PSIni (Get-IniContent). I have a format that works but generates too much data. My ini file looks like this : [General settings] gensetting1=random ...
3 votes
1 answer
11k views

Missing roles in Windows Server 2016

I'm trying to install the NPS role on Windows Server 2016 (Datacenter) but neither Server Manager nor Install-Windows feature seem to be aware of its existence: PS > Install-WindowsFeature NPAS -...
0 votes
1 answer
1k views

Extract data from multiple XMLs and generate CSV report - Powershell

I have few connectionstrings which are xml files. I need to generate a CSV report using all these connectionstrings with the following output: Below is my PS script which works fine for 1 file and ...
1 vote
2 answers
827 views

Test if PowerShell script being called with Invoke-Expression?

Is there a way to tell if a script is being called using Invoke-Expression rather than called directly? I want to do something different, e.g. pause for input, if the script is being called directly ...
2 votes
2 answers
545 views

Knife not parsing JSON variable in PowerShell

I am trying to create an amazon EC2 instance using "knife ec2 server create" and passing in JSON to override the default settings by using the -j option where $json is properly formed JSON text and I ...
2 votes
1 answer
2k views

Powershell Remoting security implications by adding users to WinRMRemoteWMIUsers

In our current workflow, we have to RDP to several servers just to know if a service is up-and-running. We do not have admin rights to those servers but are allowed to view, start and stop services. ...
-2 votes
2 answers
1k views

Powershell script to restore VM from snapshot [closed]

I'd like to write a script that restore a Virual Machine in Hyper-V from a snapshot once every 20 days. I know that the automation can be achieved by using Windows Task Scheduler. The main problem is ...
0 votes
1 answer
2k views

Run powershell.exe as a service, or help me find an alternate solution

Summary: I need to run a Powershell script continuously in the background whether a user is logged on or not. This is on Server 2012. I ran the following command: sc.exe create "MyService" binPath="...
2 votes
1 answer
360 views

PowerShell 'if' mechanism dependant on VM State

I'm new to PowerShell and am trying to write a script that's dependant on a Hyper-V VM's status. Here's my (basic) if statement: if((get-vm WMDC2 | out-string) -like '*Running*') { echo "running"} I ...
0 votes
1 answer
731 views

GWMI - Find out if Domain Controllers are physical or virtual via script

I have tried to create a script for extracting but the output is not quite I desired. $Servers = Get-ADDomainController -Filter * | Select-Object Name foreach($server in $servers) { $compsystem = ...
1 vote
1 answer
390 views

Installing nginx through Powershell in Amazon EC2

I have an Amazon EC2 instance. I want to install nginx web server on it. I have established a connection in Powershell(Windows 10) to the server. PowerShell screenshot I have searched but haven't ...
2 votes
2 answers
377 views

Allow user create Hyper-V VM

The project is to automate VM creation. The server is Windows Hyper-V Free 2016. Following the blog post https://www.starwindsoftware.com/blog/automate-the-hyper-v-virtual-machine-deployment-with-...
1 vote
1 answer
980 views

List Local Users, group membership and Enabled status to single csv file using Powershell

I'm trying to create a .csv file listing all local users, each user's group memberships and whether or not the user account is enabled using Powershell. I have found this answer that I've been able ...
0 votes
1 answer
1k views

Quest PowerShell: Export AD permissions and apply them at a later stage

I'm trying to standardise our AD permissions for our 4 support groups. I've already applied permissions for 2 standard groups (Global support) and I'm now facing a painful clean-up for site based ...
0 votes
1 answer
2k views

Exchange 2013 new-mailboxsearch searchquery combining two conditions

I'm conducting an email search with a complex query using powershell, and I'm having trouble combining two conditions. I've got a list of email addresses that I want to search to/from, and a list of ...
0 votes
1 answer
737 views

Use for [$i] variable to create csv columns - Powershell

I am trying to grab information from the connectionstrings.config file and populate it to a CSV. I have the following script so far: $Filename = "C:\new.config" [xml]$config = Get-Content $fileName $...
3 votes
1 answer
16k views

Create multiple triggers in scheduled task

Server 2012 I have an existing scheduled task that I would like to add multiple triggers to. I do this: $trigger = New-ScheduledTaskTrigger -At 1PM -Once Set-ScheduledTask -TaskName "Task Name" -...
1 vote
2 answers
858 views

Regex works everywhere ( tried regex101 and regstorm.net) except Powershell

I have tried various different combos and already checked other similar posts, but can't find my answer. I have a .config file and I need to exclude the comments from the file when I do my search, ...
2 votes
1 answer
2k views

Powershell 2.0 : issue import-Module in a background job

I launch a script in backgroung using Start-Job command. In this script, I load a module using Import-Module. The job stay blocked in the running state at the Import-Module step. The same behaviour ...
1 vote
1 answer
1k views

How can I change a substring of a custom attribute in Powershell?

I'm sure this is fairly basic but I can't seem to wrap my head around it and at this point it would almost be more prudent for me to do it manually but it seems like a good learning opportunity. I ...
1 vote
2 answers
353 views

Cloudberry Explorer PowerShell error

I am trying to automate pulling files from Amazon S3 storage to a local disk using a Cloudberry Explorer PowerShell script. Using the Desktop app, I am able to manually connect and bring files over to ...
11 votes
5 answers
59k views

Can't give 'send-as' permissions in Exchange 2010

I'm trying to give 'send-as' permissions to one user in Exchange 2010. Here is the Powershell command I'm running: Add-ADPermission "User1" -User "Ourdomain\User2" -Extendedrights "Send As" ...
1 vote
2 answers
4k views

Powershell 2: How to find arbitrary object in AD having a specific email address?

I am 3-to-4 weeks new to powershell and using it to interact with Active Directory / Exchange. (Both of which I'm also very new to.) I've tried reading this page: http://technet.microsoft.com/en-us/...
11 votes
5 answers
69k views

How to find the creation date of a local user account?

I would like to get the creation date of a local user account (Win 7 if it matters). I've looked at the following WMI objects (and google of course): Win32_UserAccount Win32_NetworkLoginProfile The ...
2 votes
1 answer
6k views

Get-Cluster cmdlet fails when using -Name param

Summary When I call Get-Cluster powershell returns the name of my cluster. For simplicity sake, lets call it Cluster1. If I call Get-Cluster -Name Cluster1 it fails with an error. Error: Get-...
1 vote
1 answer
628 views

HP iLO Powershell Management: Send Key while in Boot Menu

Scenario: I try to automate Windows Deployments on HP Gx Servers with the powershell management for iLO. I managed to start & stop a server, insert a disc and change the boot priority. It all ...
2 votes
1 answer
142 views

user account used as a service account

I have a user who has set up a few services running on their domain user account - the problem is that he doesn't remember where he set his account up like this. Is there anyway to see what his ...

1
36 37
38
39 40
83