powershell

Dropping Users from SQL Server Database via Powershell

末鹿安然 提交于 2021-01-28 08:31:13
问题 I am trying to drop users from a SQL server database via PowerShell using the following code: $sql_server = "mysqlserver" $dbname = "mydb" [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server")($sql_server) $db = $server.Databases["$dbname"] $logins = $db.users if ($logins.count -gt 0) { foreach ($login in $logins) { if ($login -notmatch "\[dbo\]|\[guest\]|\[INFORMATION_SCHEMA\]|\[sys\]") {

How to create a video from frames named using timestamp with ffmpeg

a 夏天 提交于 2021-01-28 08:22:11
问题 I have a folder filled with frames that have the timestamp in the name in the folowing format im_%H_%M_%S_%MS.png im_08_05_09_007324.png im_08_05_09_532857.png im_08_05_10_059340.png im_08_05_10_575862.png im_08_05_11_118361.png im_08_05_11_596814.png im_08_05_12_148340.png im_08_05_12_665838.png I try to use -pattern_type glob in windows but it does not work. ffmpeg.exe -framerate 10 -pattern_type glob -i im_*.png -c:v libx264 -r 30 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -pix_fmt yuv420p

Error trying to implement IValueConverter in PowerShell - XAML GUI script

别来无恙 提交于 2021-01-28 08:22:03
问题 What am I missing? I was trying to implement converters to my XAML-based PowerShell script but with no luck. I've picked up pieces of information from sites like StackOverflow. but couldn't find one successful implementation of a converter in powershell XAML-based GUI script. in the code I am testing the converter, and it works (you can see 2 examples for conversion) so that means that powershell itself accepted the new converter type, buy this converter cannot be implemented in my xaml code.

How do I force a function to return a single element array instead of the contained object?

左心房为你撑大大i 提交于 2021-01-28 07:52:54
问题 I have a function (actually several instances of this), but there are times that it may return a list of several elements, and there are times that it may return a single element. I want the function to return an array ( [System.Object[]] ) every time so that (on the receiving end), I can always anticipate it being an array and index into it, even if I am just pulling the 0th element. I've tried casting the return type multiple ways (see code below) ... including (for example) return @("asdf"

In Powershell how do I get Select-Xml to search multiple Nodes

非 Y 不嫁゛ 提交于 2021-01-28 07:47:58
问题 So I got to say that I m new to using PowerShell for parsing out XML. With that said, how to do I combine multiple -XPath So that I can finishing building out my expression report. Please let me know, I have tried several combinations and none of them seem to work with namespace XML. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" niaVersion="12.0.0.756" xmlns="http://something.com/something

Waiting for a specific event in Powershell

隐身守侯 提交于 2021-01-28 07:45:04
问题 I am writing a script in powershell, that will wait for a specific event in Windows 7. Event ID 4776, in the Security Log. The script will run when the computer is locked. The script is supposed to run in idle, essentially a while(true) loop, and it will wait for the "Failed Audit" of the event to occur. Once the event happens, it will add one to a counter. Once the event happens in a "Success Audit" status, it will break from the loop and thus be done with the script. My initial idea, was to

How to update Azure Application Gateway Path Based Rule UrlPathMap from .NET

巧了我就是萌 提交于 2021-01-28 07:19:27
问题 On Azure Portal, I am able to setup path-based rules which have some default setting, and a list of sub-rules (UrlPathMap). Each of those sub-rules has a name, paths, backend pool, and HTTP setting that have to be configured. As I can see I can update this map easily through Azure Portal. I want to be able to create such sub-rules dynamically from code as part of the application installation. I would prefer to do this directly from .NET (ASP.NET Core 3.1) application, but Azure CLI or Azure

Evaluate a variable within a variable in Powershell

早过忘川 提交于 2021-01-28 07:15:16
问题 I have the following variables: [string]$eth_netmask = "ext_netmask" [string]$ext_netmask = "255.255.252.0" $($eth_netmask) is returning ext_netmask . I was expecting 255.255.252.0 What am I doing wrong? Thanks for the help in advance! 回答1: The command $eth_netmask returns the value of the variable named eth_netmask. The expression $(something) has nothing to do with variables, but instead evaluates the contents of the parentheses before evaluating the rest of the statement. That means that

Command “docker” not recognized in windows powershell

心已入冬 提交于 2021-01-28 07:01:02
问题 I am using Windows Powershell (on windows 10). I am also using the latest version 2.3.0.5 of docker desktop. When I type "docker version" in powershell the command is not recognized. The error message reads "Der angegebenen Datei ist keine Anwendung zugeordnet." (English: No application is assigned to the specified file). When I instead include the file extension and type "docker.exe version" the command can be executed. The interesting thing is that "docker version" works in a cmd window,

Convert from PSObject to Datatable

谁说胖子不能爱 提交于 2021-01-28 06:53:31
问题 So essentially I'm parsing content from http://www.webcal.fi/en-GB/other_file_formats.php via Invoke-WebRequest and converting this from JSON into a PSObject via the ConvertFrom-Json cmdlet. Now I need to get that data into SQL, and the most effective way I can think of (with the ability to re-use pre-existing functions I have already) is to get this PSObject converted into a Datatable . I can't seem to think of any easy way to achieve this while keeping it generic, I don't want to hard-code