powershell-4.0

Parse ATOM rss feed and remove html tags

落爺英雄遲暮 提交于 2020-05-24 05:41:39
问题 am developing this code using powershell. I need to be able to extract the html tags. Invoke-WebRequest -Uri 'https://psu.box.com/shared/static/jf36ohodxnw7oemghsau1t7qb0w4y708.rss' - OutFile C:\users\anr2809\Documents\alerts.txt [xml]$Content = Get-Content C:\users\anr2809\Documents\alerts.txt -Raw $Regex = '(?s)SE1046.*?Description := "(?<Description>.*?)"' If ($Content -match $Regex) { "Description is '$($Matches['Description'])'" # do something here with $Matches['Description'] } Else {

Break lines in powershell array and then convert it to html?

我的梦境 提交于 2020-05-08 18:48:15
问题 I swear I've been searching a lot and still haven't found any solution to this thing. What I do is basically converting arrays to HTML but I can't find any way to break the words of the array in new lines. For example: $Member.ExpireOn=((Invoke-SqliteQuery -SQLiteConnection $C -Query "SELECT expireon FROM exceptions_test WHERE (identity='$User')").ExpireOn -join "`r`n") $Member.ExpireOn is basically this: 31/01/2019 00:00:00 31/03/2019 00:00:00 31/03/2019 00:00:00 so even if I join it with

Output the date/time in PowerShell

一笑奈何 提交于 2020-04-09 05:23:33
问题 I want to output the date time in various places in my script for logging so I am doing this: $b = Get-Date Write-Output "Backups complete at $b" # more code here $c = Get-Date Write-Output "Backups complete at $c" I am having to use multiple letters of the alphabet to get the most current date/time. Is there an easier way of doing this or do I have to reestablish the date each time I want to use it again? 回答1: Once you assign the current datetime to a variable, you are capturing the date and

Output the date/time in PowerShell

一曲冷凌霜 提交于 2020-04-09 05:22:15
问题 I want to output the date time in various places in my script for logging so I am doing this: $b = Get-Date Write-Output "Backups complete at $b" # more code here $c = Get-Date Write-Output "Backups complete at $c" I am having to use multiple letters of the alphabet to get the most current date/time. Is there an easier way of doing this or do I have to reestablish the date each time I want to use it again? 回答1: Once you assign the current datetime to a variable, you are capturing the date and

Output the date/time in PowerShell

浪子不回头ぞ 提交于 2020-04-09 05:22:10
问题 I want to output the date time in various places in my script for logging so I am doing this: $b = Get-Date Write-Output "Backups complete at $b" # more code here $c = Get-Date Write-Output "Backups complete at $c" I am having to use multiple letters of the alphabet to get the most current date/time. Is there an easier way of doing this or do I have to reestablish the date each time I want to use it again? 回答1: Once you assign the current datetime to a variable, you are capturing the date and

Block a file with Powershell

↘锁芯ラ 提交于 2020-03-04 05:41:29
问题 I want to block (not unblock) a file with Powershell. I want to cause Windows to believe that a file on disk was downloaded from the internet, or whatever other scenario exists such that files become blocked. I need this to test how some software I'm developing behaves in the presence of a blocked file. 回答1: If you're just trying to add the zone identifier you could try something like this: $data = "[ZoneTransfer] ZoneId=3" Set-Content example.txt -Stream "Zone.Identifier" -Value $data 来源:

Counting Folder Depth with PowerShell

橙三吉。 提交于 2020-02-28 07:40:31
问题 1. Code Description alias how it is intended to work User enters a path to a directory in PowerShell. Code checks if any folder within the declared directory contains no data at all. If so, the path of any empty folder will be shown on the prompt to the user and eventually removed from the system. 2. The Issue alias what I am struggling with The code I just wrote doesn't count the depth of a folder hierarchy as I would expect (the column in the output table is blank). Besides that, the

Counting Folder Depth with PowerShell

江枫思渺然 提交于 2020-02-28 07:40:11
问题 1. Code Description alias how it is intended to work User enters a path to a directory in PowerShell. Code checks if any folder within the declared directory contains no data at all. If so, the path of any empty folder will be shown on the prompt to the user and eventually removed from the system. 2. The Issue alias what I am struggling with The code I just wrote doesn't count the depth of a folder hierarchy as I would expect (the column in the output table is blank). Besides that, the

Unable to install WMF 4.0 for Window 7 SP1

偶尔善良 提交于 2020-02-06 07:40:46
问题 I am trying to install Windows update for Installing Windows PowerShell 4.0. The Update is : Windows6.1-KB2819745-x64-MultiPkg.msu at This Link Following are my system Specifications: I already have prerequisites to install WMF 4.0 which are SP1 and .NET 4.5. I get a simple plain error with no details that update can not be installed. what can i do to install this particular update? Just in case anyone want to know, I need to install this update to Install KVM required for building VNext Apps

Test if Wireless Adapter is Working Before Resetting

三世轮回 提交于 2020-02-05 02:14:07
问题 Is there a simple way to prove if a network adapter is working? Perhaps some IP like localhost (127.0.0.1) which is always available regardless of which network I'm connected to; only one that only shows if my wireless network adapter's working? Or perhaps there's some simple diagnostic check to confirm this? I've tagged this question as PowerShell as that's my preferred language; but I can figure out ways to integrate with any other solutions which may be suggested. Tried so far I thought of