Questions tagged [powershell]

28128 questions
1

votes
0

answer
63

Views

Same command to copy directory in Windows as well as Mac

I want same command to copy directory in Windows as well as Mac. I don't want two different commands cp in terminal in Mac and xcopy in PowerShell in Windows. Is there a single command which can used in both Mac and Windows without any changes?
user43286
1

votes
1

answer
1.3k

Views

Powershell Copy-Item -Destination [duplicate]

This question already has an answer here: Powershell 2 copy-item which creates a folder if doesn't exist 8 answers Get-ChildItem -Path \\$SiteMachineName\c$\ProgramData\Scripts\log -Recurse | Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-40)} | select * | Select -ExpandProperty FullName |...
Minerbob
1

votes
2

answer
610

Views

powershell copy-item doesn't copy when filter is used

I'm trying to copy files using copy-item. Specifically, I want to copy files with a particular extension that are within a folder or its subfolders to another location, and to retain the subfolder hierarchy. I've tried using -filter and -include to specify the file extension, but no files are copied...
Peter
1

votes
1

answer
178

Views

Get-AzureRmConsumptionUsageDetail not returning data this week

We burn through about $2,500 / month in Azure services, meaning we have plenty of services that we are getting billed for each day. I use the Azure Powershell command Get-AzureRmConsumptionUsageDetail to get my billing data each day. For billing dates after 12/21/2017 the powershell command does not...
Terrence
1

votes
1

answer
117

Views

Exchange Powershell attempting to gather all mailboxes that have send as permissions granted

I am working on a migration from on premise Exchange 2010/2013 to Office 365 Exchange online. I am trying to collect a report of all mailboxes of user type and shared type that has send as permissions granted; as well as the names of the mail users that have been granted the permission. The code...
CBeale
1

votes
2

answer
106

Views

add archive bit on files older than 14 days via PowerShell

I am trying to setup a PowerShell script which will add an archive bit to all the files which are older than +14 days in a specific folder, for example C:\Temp. This is possible via CMD, but how do I manage to add the +a bit only to files older than +14 days? attrib +A C:\temp\*.*
user2602460
1

votes
1

answer
73

Views

Cannot recursively remove certain files with Remove-Item -Recurse -Force

On powershell 5.1 Using this within a foreach loop, ex: foreach ($i in $folder.subfolders) { if( $i.path -like '*node_modules' ){ Remove-Item $i.path -Force -Recurse } } I keep running into this particular error: + CategoryInfo : WriteError: (_node_modules_r...dationpath.html:FileInfo) [Rem...
zhzoo
1

votes
2

answer
360

Views

Enumerating local groups using Invoke-Command on remote machines

I have an issue with a function I've wrote to return members of local groups when it is run against a remote machine. We use secondary domain accounts for admin privileges so I've used Invoke-Command so we can run the script block with that account, however, when I do this as opposed to running a ne...
Ash
1

votes
0

answer
298

Views

Docker for Windows - Install certificates using sn.exe / Strong Name utility

We have a Docker image that we use to build our Visual Studio solutions. This works great. Now we have some solutions that require a key. To install the key you use sn.exe, but Microsoft has gone through great lengths to make sure human input is needed, namely the password.. The image is based off F...
Thomas Rijsewijk
1

votes
1

answer
148

Views

Build unsafe code in PowerShell 6

I know how to build library with unsafe code in PowerShell 5 (and less) but I can't do same in PowerShell 6. In fact, PowerShell 6 is based on .NET Core that's why Add-Type cmdlet haven't -CompilerParameters. Should I use third party libraries to solve my problem? Is there a way to build unsafe code...
2

votes
3

answer
156

Views

How do I properly use ForEach() statement of List?

I'm confused what I'm doing wrong in ForEach method syntax of List? PS D:\ntt> $nicInfo.IpConfigurations.Count 2 PS D:\ntt> $nicInfo.IpConfigurations[0] PrivateIpAddressVersion Name Primary PrivateIpAddress PrivateIpAllocationMethod Subnet Name PublicIpAddress Name ProvisioningState -----------...
Gregory Suvalian
1

votes
1

answer
50

Views

I'm trying to integrate a folder browser dialog into this batch Mkvmerge Script

I want to add a folder browser dialog to this MKVMerge script. I don't know how to take the result of the dialog to specify the script's target directory. Can someone please help me integrate them? #Set MKVMerge.exe Path $MKVMerge = 'C:\Program Files\MKVToolNix\mkvmerge.exe' #Set Target $Director...
Jared D
1

votes
1

answer
156

Views

Config file: import localization error

I am trying to import a PowerShell config .psd1 file. I tried two ways and both case I get the following error. Import-LocalizedData -BaseDirectory .\ -FileName bootstrap.Config.psd1 -BindingVariable ConfigData OR $ConfigData = Import-LocalizedData -File bootstrap.Config.psd1 I don't need any local...
masiboo
1

votes
1

answer
45

Views

How to copy a folder whilst excluding some sub folders in powershell

I am very new to PowerShell and i am trying to copy a folder without some sub folders to a different folder. I have included my code below. Hope this makes sense. $from = 'C:\erp\github\bliss_' $to = 'C:\erp\websites\bitesize' $ExcludeFolders = @('.git','DHTMLX','mflasite','nbproject','.gitignore')...
Cheviwa
1

votes
1

answer
301

Views

How to map multiple share drives upto 22 at a time using powershell?

I have about 9000 DFS share drives in my environment. Unfortunately since there is no easy way to find out the size of each share drive with powershell i am trying to map 22 at a time and save the dump the results to csv file So i am trying something like this $csv=Import-Csv 'path' $csv.Name foreac...
scriptnoobie
1

votes
2

answer
605

Views

Powershell Script Start-Process is not working

I have a Problem with my script, and I can't find the solution. Allways when I try to run this script it says: Cmdlet Start-Process an der Befehlspipelineposition 1 Geben Sie Werte für die folgenden Parameter an: FilePath: What does this mean? I know I'm not very good in Powershell, just began to s...
andràs Horber
1

votes
2

answer
915

Views

Powershell convert string to date

I am putting together some custom monitoring solutions and the logs include different date/time entries. Trying to parse the date/time (text value) from the log and convert into a date value so that I can compare with others or with system date. I have used the following in the past, but am having t...
Allin Brown
1

votes
0

answer
96

Views

Publishing an azure web service takes 30 min or more? Is this normal?

The azure powershell command Publish-AzureServiceProject is taking upto 30min or more to successfully publish an application. We run the following azure powershell command. Publish-AzureServiceProject -Package 'C:\tca\tick\712fd6c47ab9a6e5\azurewebsite\Weingartner.Distribution.Azure.cspkg' -Slot...
bradgonesurfing
1

votes
2

answer
1.8k

Views

An exception occurred during a WebClient request (Powershell)

I'm trying to copy a directory folder from our HTTP server using Powershell, I would like to copy it's entire contents including subfolders into the local drive of my current server. The point of this is for server deployment automation so that my boss can run my powershell script and have an entire...
Brooke Taylor
1

votes
0

answer
338

Views

DDEAUTO: Invoke powershell with an encoded command

I have a base64 encoding of a command (6475 characters) and I can successfully execute it from the cmd.exe command prompt with powershell -e base64_string, but when I create the following field in Word: { DDEAUTO c:\\windows\\system32\\cmd.exe '/k powershell -e base64_string' } I get an error from p...
Aayla Secura
1

votes
0

answer
171

Views

PowerShell and .NET delegates (Event Tracing for Windows)

I'm trying to use krabsetw library (https://github.com/Microsoft/krabsetw) from a PowerShell script. The script is able to create a session and configure it correctly, but failed to consume any events. Script: Function Parse-ETW() { Param([O365.Security.ETW.IEventRecord] $record) Write-Host $record....
MotiB
1

votes
2

answer
283

Views

windows schedule task could not successfully run at startup

I use a script to create a windows scheduled task to call a powershell script in elevated mode to run windows update by using boxstarter (a tool could automatically continue running code even there is reboot during the execution) when system startup. But not sure why, the task could be called after...
Ian M
1

votes
0

answer
295

Views

Read package.json from TFS agent Build using powershell script?

I'm trying to get version field from package.json file of my .net core project, PowerShell Task is excuted after excuting Get Resource Task, i used this script powershell witch work perfectly in my local my machine : $package_json_path = (Get-Childitem -LiteralPath .\ -Include package.json -Recu...
Boubakr Echieb
1

votes
2

answer
150

Views

Problems with double curly brackets with cmdlet Get-Content of HTML files

I am calling Get-Content to retrieve an HTML Page which contains standard string place-holders (like '{0}','{1}' etc.) so to allow using the -f operator for population. The HTML page has a CSS Styling which requires curly braces but those conflict with the -f operator. I want to keep the HTML pag...
ChiliYago
1

votes
1

answer
18

Views

Adding an additional parameter to a powershell command changes output from a delimited matrix to a long list

Why when i run: Get-Service | select-object Status, Name, DisplayName, @{Name='ComputerName';Expression={$env:COMPUTERNAME}} do i get a delimited matrix output like: Status Name DisplayName ComputerName ------ ----...
linux_driver
1

votes
3

answer
145

Views

Remove Permissions from android manifest xml file with powershell script

I have a manifest file containing following content. I want to remove last two permission through powershell but unable to do this. I am able to get required permission but not able to remove. Here is the script I used to get content. $androidManifextFile = 'C:\Users\BilalAbbasi\Desktop\Temp\Android...
Bilal Abbasi
1

votes
1

answer
209

Views

Error when login using service principal in Powershell on Linux

I have installed Powershell on Ubuntu 16.04 and trying to login using service principal. Get Credential:- $cred = Get-Credential -UserName $applicationId -Message 'Enter Password' PowerShell credential request Enter Password Password for user $applicationId: ******************...
Galet
1

votes
2

answer
237

Views

Azure VMSS with Powershell DSC disabled TLS 1.0 cannot download script

I have a DSC script that configures a VMSS on Azure. Part of the script disables TLS1.0 and TLS1.1 client and server roles. After disabling, the VMSS cannot download the DSC script in the zip file anymore. Says it timed out after 29 attempts. If I enable the TLS protocols, it works again. Is the...
MPavlak
1

votes
1

answer
31

Views

Issue with Powershell Excel attempting to cast .csv Values

At this point, I believe it may be a file I/O issue. While utilizing a Powershell script invoking Excel methods to go through a .csv file from a website, powershell is attempting to cast placeholders for data that is too long for a cell '#######' instead of the date and time contained within the '...
LifeOfThePotty
1

votes
0

answer
780

Views

export all settings of Office 365 with powershell

I found lots of resources how to manage content on O365 with powershell, but not much regarding to manage the settings. For audit reasons, we need to check time to time that all the settings within O365 are correct and according to company policy. This goes over literally all options in all admin...
vilmarci
1

votes
0

answer
266

Views

Use InvokeMember to get a collection

I'm trying to use PowerShell to interact with SAP's Universe Design Tool (UDT) via its COM SDK. I've had success getting/setting the root object's properties: # create UDT instance $designer = New-Object -ComObject Designer.Application # get the version [System.__ComObject].InvokeMember('Version',[S...
craig
1

votes
3

answer
41

Views

Issue with searching for strings in text in Powershell

I am building a script to monitor backups with Ahsay in PowerShell and have run into an issue with identifying backup types, it works by checking for certain keywords in the first few lines of the log file, and I want to have it so that if it contains the word 'File List' but also contains the word...
Tom Halverson
1

votes
1

answer
316

Views

Powershell Wait for Specified Key to Be Pressed Otherwise Timeout

I would like to let the user to enter a specified key (e.g.: $ ) within 5 seconds. If the user cannot enter the specified key, it will become time out. $host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') This method allows the user to enter a key, but the console will continue to wait for input, which...
DanEng
1

votes
0

answer
264

Views

Why does my Azure Powershell runbook get suspended when executed as a schedule and how do I prevent retry?

I am very new to Azure Automation Runbooks but I have been authoring a powershell script that performs a backup of a SQL Azure database into a bacpac file to a blob storage container which then get's uploaded to Google Drive for an 'offsite' backup. I have implemented this functionality as 1 month a...
The Senator
1

votes
1

answer
845

Views

How to set Assigned Access for Edge Browser

I would like to set Edge as an Assigned Access to a User. I'm using the following PowerShell Command: Set-AssignedAccess -AppUserModelId Microsoft.MicrosoftEdge -UserName xy But I always get the following error (translated from German): System error 1376 has occurred. The specified local group does...
SimonS
1

votes
0

answer
372

Views

How to pre-fill RDP username & domain using mstsc in powershell

Currently, have two domains in which our users will have machines existing in either or. I am writing a powershell script in which I collect the user name and machine name. I think perform a test-connection to determine which domain the machine resides by pinging $computer.domain.com then if fails p...
Ryan Lynch
1

votes
0

answer
40

Views

Information stream in Powershell classes

I recently wrote a script using PS classes. To get status infos, Write-Information was used. For some reason, this messages can not be captured using the InformationVariable. Below is a test script to demonstrate what happens. Class Test1 { Test1() { Write-Information 'Entering Test1()' } } Class Te...
JuergSteiger
1

votes
0

answer
57

Views

How to create powershell proxy functions module in multiple files?

In our automation framework, lot of proxy functions are being created. Normally proxy function will be created by wrapping a function into another function. But our team is creating proxy function by wrapping functions into ScriptMethod. They are doing this to use member variables inside function....
Samselvaprabu
1

votes
2

answer
179

Views

Running Python Function from PowerShell

I have a .py file with a script. I want to run it from the PowerShell. I can do it by writing: C:\Users\AAA\AppData\Local\Continuum\Anaconda3\pythonw.exe 'X:\Data\_Private\Data\test.py' However I want to pass some arguments to the script. Thus, I set all script as a main(argument1, argument2) funct...
Aertonas
1

votes
1

answer
436

Views

SQL Query Result to PowerShell object

I'm looking for a way to map a query result, which I'm receiving from my orchestrator runbook. I need to map this query result into a PowerShell object to work with it. The query result looks like this: 9;Taskname;username;09.06.2017 00:00:00;10;3,24;Taskname2;username2;21.07.2017 00:00:00;0;7,25;ta...
SteelNation

View additional questions