Questions tagged [PowerShell] (327)

1
answer

The script add a variable address?

Salute. Task: to add to the number of mikrotiks 192.168.1.1 192.168.2.1, etc addresses to the ip tunnel. The question of how to automate this? If it is known that, for example, 192.168.1.1 - will address 172.0.1.1 to 192.168.2.1 - 172.0.2.1 ip address add address=172.0.1.1/32 interface=IP_tunnel network=172.0.1.1 . Usually...
francesco.Zulauf asked April 19th 20 at 12:22
1
answer

The inclusion of one ps1 to another?

Someone how to connect the files without the package installation? The universal, which did .(Join-Path -Path (Split-Path $script:MyInvocation.MyCommand.Path-Parent) -ChildPath ".\any.ps1") I would like .(Join-Path -Path (Split-Path $script:MyInvocation.MyCommand.Path-Parent) -ChildPath ".\PS.Get-Include.ps1") Get-Include ...
shanelle47 asked April 19th 20 at 12:16
1
answer

How to highlight certain values by date?

All welcome! There is a script which collects the server logs for specific events. $servername = "111.domain.com" $username = "DOMAIN\user" [xml]$equery = @" <QueryList> <Query Id="0" Path="Microsoft-Windows-TerminalServices-Gateway/Operational"> <Select Path="Microsoft-Windows-TerminalServices-Gateway/Op...
Annette asked April 18th 20 at 13:29
1
answer

Windows 10 Power Shell command Get-ExectionPolicy't understand what to do?

Good day, help please In Windows 10 start Power Shell as administrator the command Get-ExectionPolicyВыдается error: Get-ExectionPolicy : Name "Get-ExectionPolicy" is not recognized as the name of a cmdlet, function, script file, or operable programs. Check the spelling of the name as well as the availability and the correc...
Lew asked April 18th 20 at 13:08
3
answers

How to run a PS script through cmd?

There is a script. $username = 'administrator login' $password = 'password' $secstr = New-Object -TypeName System.Security.SecureString $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)} $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr Start-Process -cred...
Shannon85 asked April 18th 20 at 12:41
1
answer

How to hide the cursor?

Is there a way to hide the caret in a PowerShell console? Version 5.1 The version with the separate exe With saw, but it would be without him. Or where is this source code to C designed in the form of calls to WinApi in PW. Here it is: [Console]::CursorVisible = $false not working.
elnora.Ruecker asked April 18th 20 at 12:34
1
answer

How in C# to retrieve data from PowerShell?

Hello. Write an application in C#. The challenge is to obtain data about computers from the domain and put them in a DataGrid. To retrieve data using PowerShell. The script is run using the module system.management.automation. Function of the treatment for PS is: private string RunPSScript(string script) { Runspace runspac...
Jeanne asked April 18th 20 at 12:25
2
answers

Bind commands in Windows?

How to set a permanent alias (bind/to attach/to register a word/phrase/team) for the system below when input run.exe or cmd.exe or powershell.exe commands like "pws" is opened, for example, Powershell? Is realized only in open session of powershell by using Set-Alias pwd c:\...\powershell.exe PS And by the way, where are ...
Rachel28 asked April 18th 20 at 12:14
1
answer

To the last folder in the path?

Blunt. There is a way: C:\test1\test2\test3 How to get string test3? To guy and to get him out of the way. Need beautiful. Something I do not see need of arguments, for example, the split-path.
cyrus.Kilback asked April 16th 20 at 11:15
2
answers

You can call your function from the script in Invoke-Command?

Ie there is a ps1 script, it has the function TestFunc and call this function Invoke-Command -ComputerName 192.168.0.1-ScriptBlock {(TestFunc "test")} Writes The name "TestFunc" not recognized as the name of a cmdlet, function, script file, or operable program. Or should I make a function in a separate script and call as...
Aurelia_Ols asked April 16th 20 at 10:34