powershell

Using Powershell environmental variables as strings when outputting files

三世轮回 提交于 2021-02-19 18:50:43
问题 I am using Get-WindowsAutopilotInfo to generate a computer's serial number and a hash code and export that info as a CSV. Here is the code I usually use: new-item "c:\Autopilot_Export" -type directory -force Set-Location "C:\Autopilot_Export" Get-WindowsAutopilotInfo.ps1 -OutputFile Autopilot_CSV.csv Robocopy C:\Autopilot_Export \\Zapp\pc\Hash_Exports /copyall This outputs a CSV file named "Autopilot_CSV.csv" to the C:\Autopilot_Export directory and then Robocopy copies it to the Network

Writing to the machine.config file in powershell

▼魔方 西西 提交于 2021-02-19 09:11:35
问题 I have been working on this script for quite some time, but had to put it to rest because I could not spend time on it. I can focus more on it now, and it seems to not work quite right, hopefully I can get some help. This script is intended to first delete a section in the machine.config, the ,ProcessModel autoConfig="true"/> line $node = $machineConfig.SelectNodes("/configuration/system.web") $node.RemoveChild(($node.SelectSingleNode("processModel"))) | Out-Null Then it write back to the

Writing to the machine.config file in powershell

依然范特西╮ 提交于 2021-02-19 09:10:14
问题 I have been working on this script for quite some time, but had to put it to rest because I could not spend time on it. I can focus more on it now, and it seems to not work quite right, hopefully I can get some help. This script is intended to first delete a section in the machine.config, the ,ProcessModel autoConfig="true"/> line $node = $machineConfig.SelectNodes("/configuration/system.web") $node.RemoveChild(($node.SelectSingleNode("processModel"))) | Out-Null Then it write back to the

Writing to the machine.config file in powershell

百般思念 提交于 2021-02-19 09:09:21
问题 I have been working on this script for quite some time, but had to put it to rest because I could not spend time on it. I can focus more on it now, and it seems to not work quite right, hopefully I can get some help. This script is intended to first delete a section in the machine.config, the ,ProcessModel autoConfig="true"/> line $node = $machineConfig.SelectNodes("/configuration/system.web") $node.RemoveChild(($node.SelectSingleNode("processModel"))) | Out-Null Then it write back to the

Asynchronous named pipes in powershell using callbacks

女生的网名这么多〃 提交于 2021-02-19 09:04:31
问题 I'm attempting to use a named pipe using a .net NamedPipeServerStream asynchronously using callbacks in powershell. I'm currently using the following code: Server side: $myCallback = [AsyncCallback]{ "Connected" } $pipe = New-Object System.IO.Pipes.NamedPipeServerStream("alert", [System.IO.Pipes.PipeDirection]::InOut, 1, [System.IO.Pipes.PipeTransmissionMode]::Message, [System.IO.Pipes.PipeOptions]::Asynchronous) $pipe.BeginWaitForConnection($myCallback, "alertCallback") Client side: $pipe =

How to execute Powershell script function with arguments using Node JS?

给你一囗甜甜゛ 提交于 2021-02-19 08:52:33
问题 I have one powershell script which has multiple function and one function is calling another function. I want to execute that function with some argument using node js. I am using node-powershell npm, but it executes only powershell command not a function. I have done this with C#, but in node js i am not able to do this. C# code to run powershell function: using (var runspace = RunspaceFactory.CreateRunspace()) { try { log.Info(domain+"," + devicetype + "," + fullpath + "," + computername +

Convert String to DateTime Object in specific timezone with Powershell

耗尽温柔 提交于 2021-02-19 08:26:23
问题 With my limited knowledge of Powershell, I'm trying to convert a string in the current from: 2020-01-23 10:06:07 to a datetime object in the timezone Eastern Standard Time . Ultimately I want to be able to format to ISO8601 standard with the correct offset from UTC. 20-01-23T10:06:07-05:00 Is this achievable within powershell? I have looked at ConvertTimeFromUtc however I am struggling to initially specify that the timezone is Eastern Standard Time instead of GMT. 回答1: To treat a given

Exit code from a batch file is not propagated to the parent powershell script

荒凉一梦 提交于 2021-02-19 08:25:07
问题 Please, observe: c:\temp\1.cmd @echo off setlocal cmd /c dir aaa IF %ERRORLEVEL% NEQ 0 GOTO fail GOTO end :fail echo - Script failed :end endlocal Now if I run it in the command prompt: C:\temp> cmd Microsoft Windows [Version 10.0.16299.967] (c) 2017 Microsoft Corporation. All rights reserved. C:\temp>c:\temp\1.cmd Volume in drive C has no label. Volume Serial Number is 4A5E-F223 Directory of C:\temp File Not Found - Script failed C:\temp>echo %errorlevel% 1 C:\temp> Now I am running it from

How can I download a file from S3 via Powershell without installing AWS SDK?

删除回忆录丶 提交于 2021-02-19 08:14:13
问题 I want to download a file from my AWS S3 bucket using Windows Powershell. I cannot install any AWS software and need to create an API to be able to access a file in AWS S3. I used Postman for testing that the file is accessible and it was successful. Given this success I tried following AWS' guide which says that I need to create the following: Create a canonical request. Use the canonical request and additional metadata to create a string for signing. Derive a signing key from your AWS

Run command line in PowerShell

流过昼夜 提交于 2021-02-19 08:11:19
问题 I know there are lots of posts regarding this, but nothing worked for me. I am trying to run this command line in PowerShell: C:/Program Files (x86)/ClamWin/bin/clamd.exe --install I have this in PowerShell: &"C:/Program Files (x86)/ClamWin/bin/clamd.exe --install" But all this does is execute clamd.exe , ignoring the --install parameter How can I get the full command line to run? 回答1: Josef Z's comment on the question provides the solution: & "C:/Program Files (x86)/ClamWin/bin/clamd.exe" -