powershell

How to close a tab in existing IE window using powershell

霸气de小男生 提交于 2021-01-28 12:41:07
问题 Hi Does anyone know how to open and close a tab in internet explorer using powershell. I am able to open one using the following $navOpenInNewTab = 0x800 # Get running Internet Explorer instances $oApp = New-Object -ComObject shell.application # Grab the last opened tab $oIE = $oApp.Windows() | Select-Object -Last 1 # Open link in the new tab nearby $oIE_Total_Sends = $oIE.navigate($link, $navOpenInNewTab) while ($oIE.busy) { sleep -milliseconds 50 } How do i close this new tab through

Use -ComObject Word.application without install Word

和自甴很熟 提交于 2021-01-28 12:38:45
问题 I have a powershell script which use "-ComObject Word.Application". I would like to use this in a windows server but it doesn't have Word. For now, when i execute , i have this error. New-Object : La récupération de la fabrique de classes COM pour le composant avec le CLSID {00000000-0000-0000-0000-000000000000} a échoué en raison de l'erreur suivante: 80040154 Classe non enregistrée (Exception de HRESULT : 0x80040154 (REGDB_E_CLASSNOTREG)). Au caractère E:\BELAIRREC\Scripts\PowerShell

Use -ComObject Word.application without install Word

本秂侑毒 提交于 2021-01-28 12:35:00
问题 I have a powershell script which use "-ComObject Word.Application". I would like to use this in a windows server but it doesn't have Word. For now, when i execute , i have this error. New-Object : La récupération de la fabrique de classes COM pour le composant avec le CLSID {00000000-0000-0000-0000-000000000000} a échoué en raison de l'erreur suivante: 80040154 Classe non enregistrée (Exception de HRESULT : 0x80040154 (REGDB_E_CLASSNOTREG)). Au caractère E:\BELAIRREC\Scripts\PowerShell

Understanding the get-culture command

你。 提交于 2021-01-28 12:04:40
问题 I recently had some trouble with culture dependent returned values from my powershell script. The same script returned different values, depending on which machine it was. So I thought that maybe the culture settings are different and for one server it returned. get-culture : de-DE for the other it was like : en-US One value is for the keyboard settings but what does the other (second) stand for? And is the second value bound to the OS installation or is that just a setting? Is there a

Convert to csv from json in powershell

我是研究僧i 提交于 2021-01-28 12:00:57
问题 this is my csv: "name,data Play,http://{gho}.domain.com/ BDomain,domain.com Charts,2 Compress,0 CompressJ,0" | ConvertFrom-Csv | ConvertTo-Json Gives me: [ { "name": "Play", "data": "http://{gho}.domain.com/" }, { "name": "BDomain", "data": "domain.com" }, { "name": "Charts", "data": "2" }, { "name": "Compress", "data": "0" }, { "name": "CompressJ", "data": "0" } ] I would now like to get that csv back from my json, however the chains of | ConvertFrom-Json | ConvertTo-CSV are not working, and

Stubborn Ampersand with Invoke-Webrequest SQL & Powershell

北城以北 提交于 2021-01-28 11:43:22
问题 When I run powershell using invoke-webrequest on a URL without an ampersand everything works. But my URL's have ampersands in them. If I surround them by double quotes it works from PowerShell, but not if I am doing it through my SQL Server. Trying to get the right combination of escape characters is proving to be a pain in the butt. Here's an example of the command: exec xp_cmdshell 'powershell Invoke-WebRequest -UseBasicParsing -Uri "https://example.com/getfile/12345&i=123" -outfile C:

How to get a lengthy string environment variable in full?

自闭症网瘾萝莉.ら 提交于 2021-01-28 11:43:13
问题 The command gci env:ApiSecret | ConvertTo-Json works to return a long string, the API secret for Twitter, which is truncated without the pipe to JSON. However, the JSON is rather spammy. Is there a "goldilocks" way to get the lengthy string value without the extraneous details? (Unfortunately, gci env: truncates the key) 回答1: Get-ChildItem is for retrieving all or a subset of items from a container. Note that it outputs an object with Name and Value properties (substituting Path as another

How to download all files from URL?

*爱你&永不变心* 提交于 2021-01-28 11:42:16
问题 I'm pretty new with PowerShell and need a script to download all files from the URL: https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/daily/kl/recent/ I already managed to download the files when I store the URLs of the single files in a List (see code). I tried different stuff to generate the list automatically, but I haven't made it. $list = get-content "D:\ListURL.txt" foreach($url in $list) { $filename =[System.IO.Path]::GetFileName($url) $file =[System.IO.Path

How to convert a response from Invoke-RestMethod to XML?

风流意气都作罢 提交于 2021-01-28 11:15:24
问题 Referencing the help file for `Invoke-RestMethod: PS /home/nicholas> PS /home/nicholas> $response = Invoke-RestMethod -Uri https://blogs.msdn.microsoft.com/powershell/feed/ PS /home/nicholas> PS /home/nicholas> $json = $response | ConvertTo-Json WARNING: Resulting JSON is truncated as serialization has exceeded the set depth of 2. PS /home/nicholas> PS /home/nicholas> $xml = $response | ConvertTo-Xml PS /home/nicholas> PS /home/nicholas> $xml.OuterXml How can I convert the response to xml and

Object Relational Mapping from CSV with PowerShell?

ぃ、小莉子 提交于 2021-01-28 10:51:54
问题 "How to iterate through CSV data from PowerShell ?" would perhaps be an alternate question title. This output is fine: PS /home/nicholas> PS /home/nicholas> $flat Date Region New_Tests Total_Tests Positivity Turn_Around ---- ------ --------- ----------- ---------- ----------- 2020-01-23 BC 2 2 0 32 2020-01-23 Fraser 0 0 0 0 2020-01-23 Interior 0 0 0 0 2020-01-23 Northern 0 0 0 0 2020-01-23 Unknown 0 0 0 0 2020-01-23 Vancouver Coastal 2 2 0 32 2020-01-23 Vancouver Island 0 0 0 0 .. but I'd be