powershell

Date Time format displays differently in ISE and Windows Forms

风格不统一 提交于 2021-02-02 09:05:44
问题 When I run Get-Date in ISE, I get Wednesday, 15 April 2020 12:38:03 PM which I want. However, if I run the same command in Windows Forms, I get 04/15/2020 12:38:03 in a different format. I run them from the same computer so it must be the same cultural/region. 回答1: 1. Customizing your date using -Format or -UFormat You can use the -Format or the -UFormat paramater to enforce a certain layout of your date: Get-Date -Format "dddd, d MMMM yyyy hh:mm:ss tt" Get-Date -UFormat "%A, %e %B %Y %r"

set FLASK_DEBUG=1 not working on Powershell

流过昼夜 提交于 2021-02-02 08:35:32
问题 I'm building a Flask application and my file " helloworld.py " is: from flask import Flask app = Flask(__name__) @app.route('/home') def hello_world(): return 'Home!' @app.route('/about') def about_us(): return 'aboutus!' My Flask code after activating venv: set FLASK_DEBUG=1 flask run Changes made to my " helloworld.py " file doesn't get automatically updated. I still have to restart it manually as I change anything in the code. There is no error thrown but the changes simply don't reflect

set FLASK_DEBUG=1 not working on Powershell

喜欢而已 提交于 2021-02-02 08:33:09
问题 I'm building a Flask application and my file " helloworld.py " is: from flask import Flask app = Flask(__name__) @app.route('/home') def hello_world(): return 'Home!' @app.route('/about') def about_us(): return 'aboutus!' My Flask code after activating venv: set FLASK_DEBUG=1 flask run Changes made to my " helloworld.py " file doesn't get automatically updated. I still have to restart it manually as I change anything in the code. There is no error thrown but the changes simply don't reflect

Windows系统运维转linux系统运维的经历

人盡茶涼 提交于 2021-02-02 05:02:49
开篇之前,首先介绍一下我的背景把:我是一个三线城市的甲方运维。最近,在 《Linux就该这么学》 书籍的影响下和朋友小A(Linux运维已经三年了,工资也比我的高很多)的影响下,决定转行。最近花了三个星期的时间学习了linux基础,想换一份linux的工作个人觉得十分困难。不禁在思考该怎样继续下去呢?其实我对自己很没有自信的,我觉得自己都不算运维:维修设备,新员工入职培训,系统升级,软件部署,倒腾数据库。就是机房是国外维护,进不去。人资,集成,软件缺人我都去帮忙。整个人都很不好。其实在入行运维之前,大家都说运维是背锅的,我当时年轻不服气,入行之后一身技术却没有得到很好的充分利用,真的做了这么久才发现运维真的是背锅的。特别是我这个岗位,不知道是个人原因还是公司原因等。 一次和朋友小A一起讨论这件事情的时候,A告诉我:“在技能方面: 首先,你是花了三个星期学linux,时间太短了点。Linux技术门槛不是很高但是也没由那么容易学习,推荐把《Linux就该这么学》这本书里面的的实验过一遍。先提高自己的技术和对于知识的理解能力。 然后,目前遇到的linux招聘很多要求会写shell脚本。建议学习,而且学了真的很有用。我觉得这是linux运维和windows运维最大不同: windows运维可以不写bat和powershell,但linux运维必须会shell语言

Search string in text file and display until the next delimiter

左心房为你撑大大i 提交于 2021-01-29 22:01:15
问题 I have got a file "servers.txt" : [Server1] Value_A Value_B Value_C [Server2] Value_A [Server3] Value_A Value_B Value_C Value_D === I need to search into this file and display the server line + all his values. Something like : $search = "server3" gc servers.txt | Select-String -Pattern $search and diplay until the next "[" (I can't tell for example, display the line+1, because the values are different, sometimes there are only 3, sometimes 1, etc.) Thanks a lot! 回答1: How about: $search =

Unable to obtain status (Disable) of Local user

我与影子孤独终老i 提交于 2021-01-29 21:56:53
问题 I ‘m trying to obtain a list of Local Users with Group Membership and Disabled status. I had some success however could not get the corresponding Disable status of each local user. I’m using WMI in conjunction with ADSI to obtain a Disable Status of local users. The Disable Status property is not available with ADSI. Since, I’m a PS newbie any alternative options or explanation would be greatly appreciated. FYI: These are standalone servers not member servers $adsi = [ADSI]"WinNT://$env

Is there a single python module for colored text output in idle, Powershell and terminal?

狂风中的少年 提交于 2021-01-29 20:59:37
问题 I need a python module that prints a colored output text for input() and print() functions which works on idle, Powershell, and Linux consols. I am just expecting few colors (no extra background features required) and the same functions should work equally on python idle, PowerShell, terminal, and cmd with full flexibility of code. 回答1: You can use 'clrprint' module which works for idle, terminal and PowerShell too pip install clrprint from clrprint import * clrhelp() # print's available

How to pass python arguments via start-process powershell

百般思念 提交于 2021-01-29 20:17:21
问题 I want to open a process as a different user for which I researched a lot and found that no cmd or python script can help me to achieve my goal, but the Start-Process command of powershell can. The issue currently I am facing is while passing arguments to my python script via Start-Process in powershell. I tried using -ArgumentList but that doesn't helped me as I have to pass arguments as a dict to python. Below is my script which I was running: Start-Process python.exe "E:\test_installer\src

Powershell output in color

风流意气都作罢 提交于 2021-01-29 19:00:53
问题 I am using a Powershell form to output some data and I am wondering how I can get the output in color? I am not using write-host. That is not what I am looking for. I know you can use -ForegroundColor for that. It's for Get-ADUser -Filter "UserPrincipalName -like 'Username'" | Select Enabled If output is False it needs to be in Red. If output is true just regular color. Anyone who can help me? Many thanks. Ralph. 回答1: A follow-up to my comment #region Begin functions and code behind function

Send Email if get content of file more than 2 line

ⅰ亾dé卋堺 提交于 2021-01-29 18:53:46
问题 This script will be sending email to myself if more than 2 lines (3rd lines onwards). I tried on below script but not managed to get any email notification. SMTP server is working fine and no issue. May I know what problem with my code? Tools: Using powershell v2.0 Using .Net 4 Window Server 2008 $Output = ".\Name.txt" If (Get-Content -Path $Output | Where-Object {$_.Count -gt 2}) { $MailArgs = @{ 'To' = "myemail@company.com" 'From' = "from@company.com" 'Subject' = "Pending. " 'Attachments' =