Questions tagged [powershell-v3.0]
For issues relating to Windows PowerShell, version 3.0.
73
questions
1
vote
1
answer
544
views
Why Get-SmbOpenFile losses the lock when file still opened at remote
I am using Get-SmbOpenFile, But surprisingly, it looses its connection and I can see that there is no lock even after couple of seconds later on the file any more, even it is still opened. I safely ...
0
votes
1
answer
278
views
How to Move Multiple VM's to Different datastore
I have tried and search multiple way to migrate VM's to different data store
$existingds = Get-Content dummy path
$newds = Get-Content dummypath
Get-Datastore $existingds | Get-VM | Move-VM -...
4
votes
2
answers
8k
views
Can I RDP through mstsc and run a script on that remote desktop?
I'm writing a powershell script which needs to RDP to a few servers and do processes there and then come back.
mstsc /v:<computer> by itself looks great as it's security/credential prompt is ...
1
vote
1
answer
494
views
Powershell Array for Path
We are trying to break the following Path from the text file, the path is dynamic in length, i.e, it can be ABC\DSD\AAR\ARE or ABC\DSD.
So we need a solution to break down the path as per the ...
4
votes
1
answer
4k
views
Error in powershell: operation requires an interactive window station
I am executing below command through autosys(scheduling tool) to stop a service but it is failing with below error. The command works fine when i run the command on RUN(WIN+R) or cmd after RDPing into ...
0
votes
1
answer
219
views
PS-Remote shell access to a user
I am currently adding Full control to an user manually. Please see below screen shot.
But this needs to be done via a PS script.I followed https://blogs.technet.microsoft.com/heyscriptingguy/2010/11/...
-1
votes
2
answers
1k
views
Powershell script Needd to set the state of Allow Remote Shell Access [closed]
I am looking for a script which will set the value to "Enable/Not Configured/Disable" of Allow Remote Shell Access in Gpedit via Powershell script.
Below value state value should get changed to ...
5
votes
1
answer
957
views
How to defrag volume using mountpoint?
I am trying to defrag the volume by optimize-volume cmdlet . I have passed mount point path. But it fails as below.
PS C:\Users\Administrator> Optimize-Volume -Path C:\Testvol1\disk
Optimize-...
1
vote
1
answer
10k
views
Why is powershell slow on my machine?
There are several virtual machines in the group, and 2 of them have really bad performance running Powershell.
A simple script like powershell.exe -NonInteractive -NoProfile -Command "Write-Output $...
0
votes
1
answer
306
views
exchange management shell script to find changes on mailbox?
I have a question to you.I have a mailbox account in my exchange server 2016 which is used a smtp address for while.and now, because of changing its alias and smtp address, is there a way to find the ...
3
votes
3
answers
15k
views
Remote Powershell not working but test-wsman does
I need to script some routine task to execute remotly from a serverA to many hosts but a couple of them fail to execute the script.
If i execute this:
$cred = Get-Credential myUser
Invoke-Command -...
1
vote
0
answers
20
views
Exchange Custom Attributes Excemptions
I am trying to create a scenario by which a resource mailbox is hidden from all users unless specified. I have found the following article that i have used to hide the resource box;
http://www....
0
votes
1
answer
600
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
0
answers
470
views
Exchange Message Tracking Attatchments
I have a requirement by which i need to export a list of all emails with an attachment that have the following words within its subject (private,confidential)
As it stands i can export all emails ...
3
votes
2
answers
15k
views
Howto check if a powershell command succeeded or not?
Is it possible to check if a powershell command succeeded or not?
Example:
Set-CASMailbox -Identity:blocks.5 -OWAMailboxPolicy "DoNotExists"
caused the error:
Outlook Web App mailbox policy "...
1
vote
1
answer
4k
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-...
1
vote
1
answer
3k
views
Failed to using powershell to get cookies
I am writing a powershell script to mimic a login process,and then catch data from web pages. I failed at the very begainning, I can't get into the login pages at all after I set up cookies.
Here is ...
1
vote
1
answer
1k
views
Microsoft Azure Runbook not executing powershell script
I'm trying to run the powershell script below in Micrososft Azure runbooks. However, I keep on getting the error:
The script is as follows:
#### Provide the computer name in $computername variable
$...
2
votes
3
answers
20k
views
Get-ADUser over multiple OUs and filter results
This script is supposed to grab users from several OUs and assign the users to one variable, then it takes the users from that variable and filters through each one based on last logon dates over 30 ...
-7
votes
1
answer
966
views
SysWOW64 access denied (Windows Server 2012 Standard) [closed]
I am trying to call:
[System.IO.File]::Delete($folder)
from the Powershell ISE (not ISEx86).
I am logged in as Domain User that is an Administrator on this machine to which I connect using RDP.
I ...
0
votes
1
answer
120
views
Printer Audit 64bit
I'm running the following script to get a report on installed printers :
https://community.spiceworks.com/scripts/show/2186-export-printer-information-to-spreadsheet?page=1
However when the script ...
1
vote
1
answer
720
views
Powershell, IIS Express, Server 2012, Microsoft.Web.Administration requires run as admin
I'm having a strange issue with Microsoft.Web.Adminstration 7.9.0.0 for IISExpress requiring run as administrator on Server 2012.
What I'm trying to do is add a Website to a custom ApplicationHost....
22
votes
5
answers
11k
views
Powershell equivalent of Ctrl+R?
In bash I can do Ctrl+R and start typing a command to have it search my history.
How do I do that in powershell?
Is there a way to bind a key to something like?
function GH($str) {get-history | ...
0
votes
1
answer
179
views
Difference between two powershell scripts
I received a script that is supposed to scan the event logs of 4 DCs, searching the event ID 4740 (user lockout). This is script number 1. Now I thought to myself, "Why scan all the DCs when I can ...
0
votes
1
answer
64
views
My script does not go to the next server
I'm trying to retrieve eventlog (with certain conditions) from multiple servers. It only checks the first server and does not move onto the next one. What is wrong with it? I tried different scripts (...
0
votes
2
answers
420
views
How to rename a non-AD computer remotely
I have the need to rename a non-ad computer that was just created with Hyper-V via Powershell scripts to a meaningful name before I connect it to the domain.
I have the local username and password to ...
1
vote
0
answers
355
views
NTFS Permission Report
Team, Can any one help me make the following changes to the script.
what it does it perfect, but when it checks for permissions. it does not seem to be able to differentiate between ALLOW or DENY ...
0
votes
1
answer
2k
views
Powershell command for extracting all users from a domain
Get-ADUser -SearchBase "dc=contoso,dc=local" -filter * -properties Name, Surname, samAccountName, Enabled, PasswordNeverExpires, PasswordExpired, PasswordLastSet, MemberOf | Select Name, Surname, ...
1
vote
0
answers
4k
views
ExportedCommand empty custom module PowerShell
I have a custom module in Powershell. It consists of two files the Copy-Move.psm1 and the Copy-Move.psd1.
In the Copy-Move.psm1 I have several functions from which I only export the function "Copy-...
4
votes
3
answers
36k
views
Find out if password expired or when it expires for user in a specific OU
Is there any powershell command that outputs the users that have their passwords expired from a specific organizational unit (OU).
If so can it be combined in a script with another command that ...
4
votes
4
answers
12k
views
Script for getting last reboot timestamp (2008r2)
I have a list of ad-integrated computers and I need a list of them with their last reboot time. I found some comands like Get-WmiObject -ClassName win32_operatingsystem -ComputerName xxx | select ...
5
votes
1
answer
18k
views
Get AD Group Member - Different Domains
I've been tasked with exporting the members of a few AD groups to .csv which I've always done in the past using the Get-ADGroupMember command in powershell, specifying the group name, selecting the ...
2
votes
2
answers
995
views
Powershell New-SMBShare not running as expected in script
I am working to move some files from one physical drive to another in large group of Windows 2012 servers. The drive letters and sizes are all the same on these servers. Basically we have a share on ...
2
votes
1
answer
3k
views
New-ADGroup with Multiple -OtherAttributes?
Keep getting "The Paramater is Incorrect". I think I'm following Microsoft's method correctly, but it's not working.
New-ADGroup -DisplayName $name -Name $grpName -Server server.org `
-Path:'DC=...
0
votes
1
answer
287
views
VBScript- Input DisplayName Output AD Username
If I had a txt file with a bunch of names:
Dan Smith
Jim Bob
Ryan Jones
etc,etc
using a VBscript could I convert the displaynames to AD Usernames?
If Powershell is only options, could you please ...
1
vote
1
answer
47
views
Delete " from a file content
I am querying list of domain joined computers using powershell as below:
dsquery.exe computer > "C:\testfolder\host.txt"
Output is working as expected, but it is as shown below:
"CN=WIN-...
4
votes
2
answers
8k
views
Version v4.0.30319 of the .NET Framework is not installed and it is required to run version 3 of Windows PowerShell
I have a server which we are using for Batch processing.
I can login to the server with svc_account and run powershell -f file.ps1 and it runs fine in either version 2 or 3 by the following -
...
4
votes
2
answers
7k
views
How to filter the Windows Security event log by SID?
I want to filter the event log for a certain user, but I don't think there's an option to search by SAMID. There is a filter by UserId though, according to here. Is the following correct syntax ...
2
votes
2
answers
7k
views
powershell format a value that's already a string
I have some values that I want formatted in a specific way. To be very clear, its an IP address octet and I want it in a "xxx" format. For example if I have a octet value of "20" I want to display ...
0
votes
1
answer
677
views
PowerShell - Server 2012 - Issue with Custom Modules Loading
I'm having a frustrating issue with our deployment script that is currently working on Server 2008 R2 and I can't get to start on Server 2012 due to issues with PS not recognizing our custom modules ...
2
votes
3
answers
7k
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)
{
...
0
votes
1
answer
5k
views
Invoke-GPUpdate fails even with firewall disabled
PS C:\Users\Administrator> Invoke-GPUpdate -Computer rim-23
Invoke-GPUpdate : Computer "rim-23" is not responding. The target computer is either turned off or Remote
Scheduled Tasks Management ...
12
votes
4
answers
30k
views
Enable Certificate Enrollment Policy and Request a Cert using PowerShell
Right now, I'm doing the following to request a cert from a CEP server:
Open gpedit.msc
Under Computer Configuration > Windows Settings > Security Settings > Public Key Policies, double click "...
0
votes
1
answer
789
views
Execute a git pull on a remote windows server [closed]
I'm trying to remotely execute a git pull on a Windows server via New-PSSession powershell script. Most git commands like status and help, but when I execute a pull command it just hangs and I confirm ...
6
votes
2
answers
8k
views
Invoke-Restmethod breaks script in PS 4.0
I had a Powershell script that used Invoke-RestMethod that was working in powershell 3.0. However, I upgraded to powershell 4.0 to fix a bug in powershell 3. When I did so, my script seems to have ...
0
votes
1
answer
8k
views
The term 'Get-ClusterResource' is not recognized as the name of a cmdlet, function, script file, or operable program
I have a powershell script that I'm attempting to execute over SSH. The command works perfectly when I run it from the server's powershell commandline.
Here is my Powershell script:
...
1
vote
1
answer
315
views
free disk monitoring windows 2012 - powershell
I have started from scratch to be able to learn how to monitor our server (only one).
$dates=(get-date).ToString("s").Replace(":","-")
$page="page"+$dates+".csv"
get-wmiobject win32_pagefileusage | ...
1
vote
0
answers
67
views
Manage UAG Server via WinRM
Does anyone know of there is a way to configure a UAG server to work with WinRM? We have a small number of servers and the "Server Manager" application as well as PowerShell are the way we generally ...
1
vote
2
answers
3k
views
"powershell has stopped working" on PS exit after creating IIS User
On a Windows Server 2012 box, I'm using PS to create a new IIS User (for automated deployments using MSDeploy). The command itself appears to work fine -- the user is created -- but as soon as I exit ...
8
votes
2
answers
8k
views
What does 'Not Present' mean in the Get-NetAdapter Powershell Cmdlet?
Server 2012, Powershell 3.0.
I'm doing some work that requires automating the enabling and disabling of network adapters. Here is an example of what I see when I run Get-NetAdapter:
Name ...