Newest powershell Questions

Q&A for system and network administrators

How can I scrape the Meraki client page for devices and their owners?

I am trying to automate a weekly process where I download a CSV copy from the Client page on the Meraki website. Before I lose you I am aware there is an API and it works very well. However there in ...

Scheduled restart of a service with powerhshell as non-admin service account

Before I get shot down, I know how to schedule a task, restart a service with powershell or give a non-admin account the privileges to restart a service. That isn't the problem. The problem however is ...

Write-Host 2x select statements with different values

I am trying to write a script that gets information about a user, including some info about their computer. The problem I am facing is that I am unable to write two different select statements (both ...

exchange 2010 - delivery reports - powershell

In ECP I can search for a message sent to a user and open up a delivery report. Specifically in the report I can see that after the message was delivered if it was then moved to a different folder in ...

Writing to a readonly property in WMI

I'm attempting to edit a readonly property in WMI. I've tried using the 'put' methods in both vbscript and Microsoft powershell, but I get the same error: "Provider is not capable of the attempted ...

Scheduled Powershell script occasionally dies midway through

I have a few powershell scripts that are scheduled, and they usually run just fine (both as a scheduled task, and when run manually) I've got an issue where occasionally, they just stop working ...

SSH from remote server, no SSH prompt

I'm trying to open an SSH connection from a remote PowerShell connection. Meaning PC1 (Windows) successfully connects to PC2 (Windows) via Enter-PSSession command. Once connected, I'm trying to SSH to ...

exchange get-distributiongroup powershell issue

I need to add a member to about 50 distribution groups. I have the list of groups in "display name" format. According to documentation the -identity parameter of get-distributiongroup takes pipeline ...

PowerShell Command to Disable PPTP Remote Access Connections

I'm trying to automate the creation of a L2TP VPN server using PowerShell but I can't find any articles or cmdlets on how to disable PPTP inbound connections in RRAS using PowerShell. Below is a ...

Active Directory manually reset password validity

I have been asked to put the following one-time password scenario in place for our (small) Active Directory domain: whenever an administrator has to manually reset a user's password, the password ...

Managing HyperV Server 2012R2 from Windows 10 powershell

I have trouble managing hosts running HyperV Server 2012R2 (the standalone HyperV installation) through PowerShell on Windows 10. While I can connect to them via Hyper-V-Manager in Windows 10 and ...

Windows Delete Folder '.'

I'm using UrbanCode Deploy for windows code deployments, and in my folder I've created a folder '.' . I've tried all the powershell remove-item commands and flags I can think of, I've tried robocopy ...

Difference between PSCP and Copy-Item in for remote copy with PowerShell

I have 2 windows-servers. I need to run a PowerShell script on server A which will transfer a file (on server A) to server B. What is the best (most secure) way to do this? I found out 2 solutions on ...

Need to get an output value to a variable in powershell

my Output is like this MPIO Disk System Disk LB Policy DSM Name ------------------------------------------------------------------------------- MPIO Disk0 Disk 1 RR ...

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 ...

Why can't my user account remove an AD Computer in Powershell?

I have created a Computer account in OU=AutoCreatedVMs,OU=Computer. I have allowed the AD Group Join-Move-Delete VMs to Create/delete Computer objects in OU AutoCreatedVMs: I have an account called ...

PowerShell script now fails with 'The client and server cannot communicate'

On a Server 2016 box we just updated it to PCI 3.1 that in effect removed TLS 1.0 from the cyphers. A PowerShell script that sent an email after a backup to our Domino 9.0.1 FP7 server now fails with ...

Group-Object - divide large group into chunks

I have a Powershell script that retrieves some data from a database, uses Group-Object to collect it into similar groups, then uses foreach to act on each group. The trouble is that some groups have ...

Clear-RecycleBin on remote computer fails

If I RDP to my Windows 2016 server (called LAUREL) and run this powershell, it works fine: Clear-RecycleBin -DriveLetter C -force However if I run from my Windows 10 workstation logged on as a ...

Create Code Signing Certificate on Windows for signing PowerShell scripts

According to this guide I tried to create a certificate for signing PowerShell scripts: CD C:\OpenSSL-Win32\bin REM Create the key for the Certificate Authority. 2048 is the bit encryptiong, you can ...

How can I use Exchange Management Shell to set the FirstName and LastName on multiple mailboxes?

I imported 100+ new mailboxes using Import-CSV and New-Mailbox and the Name and DisplayName fields have been populated correctly however seems I missed setting the FirstName and LastName fields. The ...

Passing list input to Get-ADComputer

SO I wrote a script that gets some information from AD about a user and their associated computer(s). I have read online about a few of the problems people face with the Get-ADComputer cmdlet and ...

Set Multiple IP Addresses For DHCP Option 6 DNS Server Using Netsh

I am trying to set two IP addresses for option 6 DNS server using this code: $serverIpAddress = '11.12.13.14' $subnet = '11.12.43.33' $value = '11.12.74.21,11.12.74.22' netsh dhcp Server $...

Renaming a computer kicks out of domain

I use a powershell script to rename hostname computer from our domain: Rename-Computer -NewName $computername -DomainCredential $mycreds -Force -PassThru Most of the time it works, but in a low % of ...

Approve WSUS Updates on WSUS Replicas using Powershell

we have 3 WSUS Replica Servers and one central server the replicas are connected to. From the central server we are managing the 3 replicas. All Clients are only connected to the replicas. I am ...

“Error trying to access object” in New-VM when creating a generation 2 VM

I have an extremely obscure error: if I try to create a gen 2 (gen 1 works fine) VM with powershell, it errors out. Creating it with the Hyper-V manager remotely works fine. Environment details: ...

Powershell script runs manually but not in Task Scheduler

I have this Powershell script and I want to schedule it run every 1 minute. So I created the task and schedule it to run every. If Right-Click->Run the scripts runs OK. But when it's scheduled it says ...

What's the PowerShell command to add server to the serverpool of RDS

We have a RDS Serverfarm containing one AD-Server and two RDS-Servers. AD is Server 2012 R2, RDS servers are Server 2016. When I login to the RDS Servers after a server restart via Teamviewer and ...

Get-DscResource not returning full list when run from Jenkins on Windows

I have a Windows Server 2016 Jenkins build box. I want to run some powershell in a Jenkins job. As a test I have set the job to do this in a Execute Windows batch command build step: powershell -...

Primary Smtp Address valid format for New-Mailbox cmdlet

I am writing simple application that utilizes the New-Mailbox cmdlet. One of parameters that is set is PrimarySmtpAddress. Provided Smtp address must be valid, otherwise the call will fail. I was ...

Retrieving Active Directory Users with no Email address [closed]

There are 1000+ users in AD. Some random users accounts (approx. 400) are created without Email address. Now I need to retrieve all those users in an Excel file who are there without Email Address. ...

How to run cmd from PowerCLI Invoke-VMScript starting with an open console

I'm trying to run a exe file in a remote machine from PowerCLI which is launching couple of cmd's. With this command: $executeCommand = "call D:\MyFile.exe Arg1 Arg2"; Invoke-VMScript -VM $vmName -...

Why is the Environment variable ClientName not updated during logon script?

I run a powershell logon script when opening RDS session on Windows 2012 R2 Server. I also run a powershell script in startup folder. When asking for CLIENTNAME environment variable in the logon ...

Azure RM NSG Port Forwarding Not Working

I have a Debian 6.x box that I needed to move to Azure. Before moving it up, I did make sure that SSH is listening on any port, so is Apache. My NSG has all of the right ports opened (22, 443 for ...

How to get the screen resolution in windows 10 with command prompt or powershell

I have been trying to run wmic path Win32_VideoController get VideoModeDescription it gives me 1920 x 1080 which is good. I change the resolution to test it and it still returns the same thing. ...

ForEach Loop Export to CSV file

I am working on creating a script that will output all the computer names and models to an excel file. The code works without the Export-Csv pipe but I can't figure out how to create the excel file. ...

How to obtain IP Address of Windows 2008 R2 VM on Hyper-V with PowerShell?

I have created an automated build script to build new VMs on Hyper-V 2016. I sometimes need a 2008 R2 VM and the way I obtain the IP Address to connect to my 2012 R2/2016 VMs is to use some powershell ...

azure port forwarding not working [duplicate]

I have a Debian 6.x box that I needed to move to Azure. Before moving it up, I did make sure that SSH is listening on any port, so is Apache. My NSG has all of the right ports opened (22, 443 for ...

Why can I set ownership with icals but not set-acl On 2K12R2?

Why using get-acl -Path 'C:\Program Files' | set-acl -Path 'D:\Program Files' as an administrator tells me I am not allowed to set the ownership while using icACLs "C:\Program Files" /save Perms.txt ...

Email reset password in Office365 using powershell

When I reset a password in the Office 365 Admin portal, I have the option to send the new password in an email, without me even seeing the password first. I know I can reset the password with Set-...

Powershell script to find and delete DNS records across multiple zones

We have multiple DNS zones, and what to find static DNS records that no longer respond to pings and delete them. I've written a PS script, but I'm having two problems. 1 - test-connection fails ...

Logging in server users after restart without using RDP [closed]

We are running instances of our software in windows server users (possibly not the best solution but this is where we're currently at) When a server is updated it forces all users on that server to ...

Use Powershell to run an elevated executable

I have an .exe that needs to run via GPO. I attempted to do it via a batch script, however it needs to run on user machines and this requires elevation as they aren't local admins. Rather than ...

Kill (close) reliability monitor windows by PID powershell

I am trying create a process of the windows reliability monitor and kill it after I take a screenshot. I am having trouble to get the process and automatically close it before I take the screenshot ...

Two Option ID 51 in DHCP

I'm using this command: netsh dhcp server \\serverName 10.11.12.3 show optionvalue and am getting back two values for option 51: Changed the current scope context to 10.11.12.3 scope. Options for ...

TrimStart() improperly truncates string

I wrote a script to backup bitlocker keys to Active Directory. The works great unless the Password ID starts with 'D'. Here is script #Get recovery info $recoveryinfo = manage-bde -protectors -get c: ...

Get-ADGroupMember Get domain of user in select-object

I've searched all over and I think this would be fairly common but maybe not. I want to list the domain of a user with the username via Get-ADGroupMember. So for instance I have this: Get-...

powershell exchange script output only works when typed manually

I'm typing the following command in exchange 2010 EMS and it works when I run it interactively. $a = Get-MailboxDatabaseCopyStatus -server theName | fl name,activedatabasecopy,status,...

Go to network share\folder with Powershell

I'm trying to access a network share in PowerShell 5.1 with elevated permissions executing the following command: gi "\\192.168.1.1\data" I'm recieving the following error: gi : Cannot find path '\\...

Is there a way to create a share that does not require username/password when accessed all through the command line?

I know there's a way to do this from a GUI (Setting up an anonymous Windows Server 2008 network share?), but I am writing a script so I want to see if you can do it without the GUI. In other words, I ...
Translating... 0%