powershell

Date conversion going wrong with different computer language

故事扮演 提交于 2020-12-06 15:46:53
问题 I wrote a Powershell script for billing of customers. I get the list of bills, detect the month and get that specific bill. The timestamps are in Unix format and somehow I mess something up in the conversion depending on system language. For example: $FirstDayPrevMonth = (get-date -Day 1 -Hour 0 -Minute 0 -second 0 -Millisecond 0).Addmonths(-1) The conversion fails for systems that return: zondag 1 november 2020 00:00:00. The conversion succeeds for systems that return: Sunday, November 1,

Date conversion going wrong with different computer language

断了今生、忘了曾经 提交于 2020-12-06 15:46:10
问题 I wrote a Powershell script for billing of customers. I get the list of bills, detect the month and get that specific bill. The timestamps are in Unix format and somehow I mess something up in the conversion depending on system language. For example: $FirstDayPrevMonth = (get-date -Day 1 -Hour 0 -Minute 0 -second 0 -Millisecond 0).Addmonths(-1) The conversion fails for systems that return: zondag 1 november 2020 00:00:00. The conversion succeeds for systems that return: Sunday, November 1,

g++ does not make any file or give any output

狂风中的少年 提交于 2020-12-06 15:37:39
问题 I've just started using g++, downloading the latest version from the site, and I've made a simple HelloWorld program. #include <iostream> using namespace std; int main() { cout << "Hello World!" << endl; return 0; } When I try to execute using the powershell window and g++, in the right directory, I use the following command: g++ HelloWorld.cpp -o HelloWorld.exe This gives no output and makes no files. I used the -v command as per some other answer I read on the site and it gave me this. I

Powershell catching exception type

人盡茶涼 提交于 2020-12-06 12:35:22
问题 Is there a convenient way to catch types of exceptions and inner exceptions for try-catch purposes? Example code: $a = 5 $b = Read-Host "Enter number" $c = $a / $b #error if $b -eq 0 $d = get-content C:\I\Do\Not\Exist Row #3 will generate a runtime error with an inner exception (EDIT: fixed this command $Error[1].Exception.InnerException.GetType()), row #4 will generate a "standard"(?) type of exception ($Error[0].Exception.GetType()). Is it possible to get the desired result from both of

Copy files to FTP and archive with today's date

最后都变了- 提交于 2020-12-06 07:52:46
问题 I need to create a script that does the following: Copies all files in a folder to an FTP site. If the copy was successful move the files to an archive. The archive should be a freshly created folder with today's date (so we know when they were transmitted). I've tried to cannibalise other scripts to get something to work but I'm not getting anywhere so I need some help I've been working on this for hours. I'm using the WinSCP DLL only because my other (working) script uses SFTP which needs

Copy files to FTP and archive with today's date

杀马特。学长 韩版系。学妹 提交于 2020-12-06 07:52:20
问题 I need to create a script that does the following: Copies all files in a folder to an FTP site. If the copy was successful move the files to an archive. The archive should be a freshly created folder with today's date (so we know when they were transmitted). I've tried to cannibalise other scripts to get something to work but I'm not getting anywhere so I need some help I've been working on this for hours. I'm using the WinSCP DLL only because my other (working) script uses SFTP which needs

SQL Server 2016 Failover Cluster + ALwaysOn

时光毁灭记忆、已成空白 提交于 2020-12-06 06:09:01
SQL Server 2016 Failover Cluster + ALwaysOn 环境的搭建 近期公司为了提高服务的可用性,就想到了部署AlwaysOn,之前的环境只是部署了SQL Server Failover Cluster,所以决定将云端放一台SQL Server来配置ALwaysOn,具体思路就是在本地的SQL Server Failover Cluster中再增加一个节点,然后将新家的节点放到Azure云端,然后在这两个实例之间配置AlwaysOn,部署后,有个问题就是集群之间无法自动故障转移,需要手动干预才可以具体后期我们再做详细介绍,废话就不多说了,开始实践配置; 环境介绍: Hostname:DC1 Role:DC IP:192.168.5.20 Domain:ixmsoft.com Hostname:ISCSI IP:192.168.5.38 Role:Storage Hostname:S1 Role:SQL Server 2016 IP:192.168.5.41 Hostname:S2 Role:SQL Server 2016 IP:192.168.5.42 Hostname:AO1 Role:SQL Server 2016 IP:192.168.5.43 SQL-CLUSTER 192.168.5.46 SQLCLUSTER 192.168.5.47

Fastest way to find a full path of a given file via Powershell?

久未见 提交于 2020-12-06 05:13:42
问题 I need to write a Powershell snippet that finds the full path(s) for a given filename over a complete partition as fast as possible. For the sake of better comparison, I am using this global variables for my code-samples: $searchDir = "c:\" $searchName = "hosts" I started with a small snippet using Get-ChildItem to have a first baseline: "get-ChildItem" $timer = [System.Diagnostics.Stopwatch]::StartNew() $result = Get-ChildItem -LiteralPath $searchDir -Filter $searchName -File -Recurse -ea 0

Fastest way to find a full path of a given file via Powershell?

六月ゝ 毕业季﹏ 提交于 2020-12-06 05:03:42
问题 I need to write a Powershell snippet that finds the full path(s) for a given filename over a complete partition as fast as possible. For the sake of better comparison, I am using this global variables for my code-samples: $searchDir = "c:\" $searchName = "hosts" I started with a small snippet using Get-ChildItem to have a first baseline: "get-ChildItem" $timer = [System.Diagnostics.Stopwatch]::StartNew() $result = Get-ChildItem -LiteralPath $searchDir -Filter $searchName -File -Recurse -ea 0

Fastest way to find a full path of a given file via Powershell?

一笑奈何 提交于 2020-12-06 05:01:03
问题 I need to write a Powershell snippet that finds the full path(s) for a given filename over a complete partition as fast as possible. For the sake of better comparison, I am using this global variables for my code-samples: $searchDir = "c:\" $searchName = "hosts" I started with a small snippet using Get-ChildItem to have a first baseline: "get-ChildItem" $timer = [System.Diagnostics.Stopwatch]::StartNew() $result = Get-ChildItem -LiteralPath $searchDir -Filter $searchName -File -Recurse -ea 0