#PSVersionTable
Explore tagged Tumblr posts
jesusninoc · 7 years ago
Text
Crear, compilar, generar y ejecutar un JAR de Java que ejecuta un cmdlet de PowerShell utilizando Runtime
Crear, compilar, generar y ejecutar un JAR de Java que ejecuta un cmdlet de PowerShell utilizando Runtime
import java.io.*; public class CrearJava { public static void main(String[] args) { FileWriter fichero = null; PrintWriter pw = null; try { fichero = new FileWriter("EjecutarPowerShell.java"); pw = new PrintWriter(fichero); pw.println("import java.io.IOException;"); pw.println("import java.io.BufferedReader;"); pw.println("import java.io.IOException;"); pw.println("import…
View On WordPress
0 notes
saprofos-blog · 5 years ago
Text
vmdk
Tumblr media
Чтобы сконвертировать образ виртуальной машины с инсталлированным «Программным комплексом С-Терра Шлюз. Версия 4.2» из формата OVA в формат VHDX выполните следующие действия:
1.   Скопируйте на хост виртуальную машину в формате *.ova.
2.   OVA – это архив, из которого необходимо извлечь файл жесткого диска в формате *.vmdk (остальные файлы можно удалить). Распакуйте архив и скопируйте файл  *.vmdk в произвольную директорию используя средства WinRAR или 7-Zip.
3.   Далее необходимо переконвертировать файл формата VMDK в файл формата VHDX. VHDX (Virtual Hard Disk) – формат файла, разработанный Microsoft для использования в качестве образа диска в гипервизорах Microsoft Hyper-V. Для конвертации образа жесткого диска используется приложение Microsoft Virtual Machine Converter.
4.   Дистрибутив Microsoft Virtual Machine Converter можно скачать по ссылке:
  https://www.microsoft.com/en-us/download/details.aspx?id=42497
5.   Выполните установку приложения. Установка не нуждается в описании, так как представляет собой типовую процедуру установки приложения.
6.   Запустите PowerShell (Win+R > powershell > Enter).
Внимание! Версия PowerShell должна быть не ниже 3. Получить информацию об установленной версии можно командой $PSVersiontable. Для более младших версий требуется обновление PowerShell.
7.   Укажите путь до скрипта конвертера командой:
Import-Module “C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1"
9.   Выполните конвертацию образа командой:
ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath "C:\*.vmdk" -DestinationLiteralPath "C:\*.vhdx" -VhdType DynamicHardDisk -VhdFormat Vhdx
где
C:\*.vmdk – путь до файла с образом в формате VMDK
C:\*.vhdx – путь до файла с образом в формате VHDX
Внимание! Для конвертирования в формат VHDX требуется ОС Windows версии не ниже 8. Для более младших версий возможно только конвертирование в формат VHD.
2. Convert VMDK to VHD
To convert VMDK to VHD, we'll need a tool offered by Microsoft called Microsoft Virtual Machine Converter (MVMC), which provides a PowerShell module to do the conversion.
Import-Module "C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1" ConvertTo-MvmcVirtualHardDisk C:\Path\to\Your\Disk.vmdk -VhdType FixedHardDisk -VhdFormat vhd
Note that -VhdType FixedHardDisk is important, as only Fixed one is supported, not Dynamic.
Note that -VhdFormat vhd is important, otherwise the commandlet may produce vhdx file depending on your operating system, and the vhdx format is not supported by Azure.
To get more help on the commandlet, type Get-Help ConvertTo-MvmcVirtualHardDisk.
1 note · View note
amalgjose · 5 years ago
Photo
Tumblr media
How to check the Powershell version ? Powershell version can be easily checked by using the following command in the powershell $PSVersionTable
0 notes
dotnet-helpers-blog · 8 years ago
Text
4 - How to validate the version of installation
4 – How to validate the version of installation
We can use $PSVersionTable.PSVersion to determine the engine version. If the variable does not exist is shown then it is safe to assume the engine is version 1.0 We also use,$Host, get-host , $PSVersionTable to get deep information about our power shell tool. Please find the snap for how to get the details.
View On WordPress
0 notes
sqlcrespi · 8 years ago
Text
Como Atualizar ou Desinstalar o Powershell 5.1
Como Atualizar ou Desinstalar o Powershell 5.1
Pessoal!
Segue o vídeo sobre como Atualizar ou Desinstalar a atualização do Powershell 5.1.
Abaixo o código utilizado na demonstração.
###Link WMF https://docs.microsoft.com/pt-br/powershell/wmf/5.1/install-configure $PSVersionTable Set-Location C:\Users\sqlcrespi\Downloads\ Get-ChildItem .\Win8.1AndW2K12R2-KB3191564-x64.msu…
View On WordPress
0 notes
stefanstranger · 8 years ago
Text
PowerShell Azure Functions lessons learned
Lately I’m playing with PowerShell Azure Functions and I learned there are some things I needed to learn and that’s why I want to share some more info about this topic.
What are Azure Functions?
Azure Functions is an event driven, compute-on-demand experience that extends the existing Azure application platform with capabilities to implement code triggered by events occurring in virtually any Azure or 3rd party service as well as on-premises systems. Azure Functions allows developers to take action by connecting to data sources or messaging solutions, thus making it easy to process and react to events. Azure Functions scale based on demand and you pay only for the resources you consume. (from Github)
On the Github page about Azure Functions you can find all the info to get started.
PowerShell Azure Functions
Azure Functions enables you to create scheduled or triggered units of code implemented in various programming languages. PowerShell is one of those programming languages.
A good starting point is a blog post from David O’Brien Azure Functions – PowerShell.
If you look at an example from David you see a special variable being used ‘$res’. At first it was not clear to me where this variable was being defined. To find out more I started to create a Function using the Get-Variable cmdlet.
Use the following PowerShell script in your Function to retrieve the automatic variables available in Azure PowerShell functions.
[sourcecode language='powershell' padlinenumbers='true'] write-Output 'Getting variables' $result = Get-Variable | out-string [/sourcecode]
If you run this in your Azure PowerShell function you will see the following in your logs section.
[sourcecode language='powershell' ] 2017-01-29T16:01:51.538 Function started (Id=6528a25c-61cc-4d16-90ad-4869e47dc599) 2017-01-29T16:01:51.867 Getting variables 2017-01-29T16:01:51.898 Name Value ---- ----- $ ? True ^ args {} ConfirmPreference High ConsoleFileName DebugPreference SilentlyContinue Error {} ErrorActionPreference Continue ErrorView NormalView ExecutionContext System.Management.Automation.EngineIntrinsics false False FormatEnumerationLimit 4 HOME Host System.Management.Automation.Internal.Host.Int... input System.Collections.ArrayList+ArrayListEnumerat... InvocationId 6528a25c-61cc-4d16-90ad-4869e47dc599 MaximumAliasCount 4096 MaximumDriveCount 4096 MaximumErrorCount 256 MaximumFunctionCount 4096 MaximumHistoryCount 4096 MaximumVariableCount 4096 MyInvocation System.Management.Automation.InvocationInfo NestedPromptLevel 0 null OutputEncoding System.Text.ASCIIEncoding outputFile D:\local\Temp\Functions\Binding\6528a25c-61cc-... PID 9936 ProgressPreference Continue PSBoundParameters {} PSCommandPath PSCulture en-US PSDefaultParameterValues {} PSEmailServer PSHOME D:\Windows\SysWOW64\WindowsPowerShell\v1.0 PSScriptRoot PSSessionApplicationName wsman PSSessionConfigurationName http://ift.tt/2g2ttdZ... PSSessionOption System.Management.Automation.Remoting.PSSessio... PSUICulture en-US PSVersionTable {PSVersion, WSManStackVersion, SerializationVe... PWD D:\Windows\system32 req D:\local\Temp\Functions\Binding\6528a25c-61cc-... REQ_HEADERS_ACCEPT application/json, */* REQ_HEADERS_ACCEPT-ENCODING gzip, deflate, peerdist REQ_HEADERS_ACCEPT-LANGUAGE en-US, en-GB; q=0.8, en; q=0.6, nl-NL; q=0.4, ... REQ_HEADERS_CONNECTION Keep-Alive REQ_HEADERS_DISGUISED-HOST stsfunctionappdemo.azurewebsites.net REQ_HEADERS_HOST stsfunctionappdemo.azurewebsites.net REQ_HEADERS_MAX-FORWARDS 10 REQ_HEADERS_ORIGIN http://ift.tt/1MC1oPy REQ_HEADERS_REFERER http://ift.tt/2g2o1rE... REQ_HEADERS_USER-AGENT Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl... REQ_HEADERS_WAS-DEFAULT-HOS... stsfunctionappdemo.azurewebsites.net REQ_HEADERS_X-ARR-LOG-ID b61667f6-86d8-4bd1-a67c-bc0821ee2170 REQ_HEADERS_X-ARR-SSL 2048|256|C=US, S=Washington, L=Redmond, O=Micr... REQ_HEADERS_X-FORWARDED-FOR 217.122.212.62:4004 REQ_HEADERS_X-FUNCTIONS-KEY EOm0H6fRai398YoJRGKkjzAZ7SV2E/zgnOjTaCOVs55W8h... REQ_HEADERS_X-LIVEUPGRADE 1 REQ_HEADERS_X-ORIGINAL-URL /api/HttpTriggerPowerShellDemo?code=fYnNjQpSyo... REQ_HEADERS_X-P2P-PEERDIST Version=1.1 REQ_HEADERS_X-P2P-PEERDISTEX MinContentInformation=1.0, MaxContentInformati... REQ_HEADERS_X-SITE-DEPLOYME... stsfunctionappdemo REQ_METHOD GET REQ_QUERY_CODE fYnNjQpSyoUtXrR3fJ/vXn/L252RcTrzaeVFGP5vsMG6aa... res D:\local\Temp\Functions\Binding\6528a25c-61cc-... result {System.Management.Automation.PSVariable, Syst... ShellId Microsoft.PowerShell StackTrace true True VerbosePreference SilentlyContinue WarningPreference Continue WhatIfPreference False 2017-01-29T16:01:52.976 Function completed (Success, Id=6528a25c-61cc-4d16-90ad-4869e47dc599) 2017-01-29T16:03:40 No new trace in the past 1 min(s). [/sourcecode]
An interesting variable is “res” if we look at the value of this res variable we see that the value in my Azure Function is D:\local\Temp\Functions\Binding\677636fe-4384-42d2-94a4-55d14101ac99\res
But I was still wondering where this variable was configured because in the examples I often saw the variable being used to output the result.
Example where $res variable is being used:
[sourcecode language='powershell' ] $Result = $psversiontable | ConvertTo-Json Out-File -encoding Ascii -FilePath $res -inputObject $Result [/sourcecode]
It turned out this variable is being configured in the integration configuration section of the Azure Function.
So in above example the output result being show when the Azure Http Trigger PowerShell Function is being called stores the output of the Result variable in a file defined in the res variable.  Hope this clarifies the $res variable seen in many examples on the internet about Azure PowerShell functions.
If you are also interested in the available environment variables within Azure PowerShell functions you can use the following PowerShell script in your Azure Function:
[sourcecode language='powershell' ] write-Output 'Getting environment variables' $result = ls env: | out-string write-output $result [/sourcecode]
I hope you have learned some new things about Azure PowerShell functions and you are interested to get started.
  References:
Azure Function on Github
Azure Functions Get Started
David O’Brien Azure Functions – PowerShell
from Stefan Stranger's Weblog – Manage your IT Infrastructure http://ift.tt/2jKSbNt via IFTTT
0 notes
jesusninoc · 7 years ago
Text
Compilar y ejecutar una clase de Java que ejecuta un cmdlet de PowerShell utilizando Runtime
Compilar y ejecutar una clase de Java que ejecuta un cmdlet de PowerShell utilizando Runtime
Tumblr media
Clase de Java que ejecuta PowerShell (la clase tiene que ser compilada) import java.io.IOException; import java.util.concurrent.TimeUnit; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class EjecutarPowerShell { public static void main(String[] args) throws InterruptedException { Runtime runtime = Runtime.getRuntime(); try { Process process =…
View On WordPress
0 notes
jesusninoc · 7 years ago
Text
Crear, compilar y ejecutar una clase de Java que ejecuta un cmdlet de PowerShell utilizando Runtime
Crear, compilar y ejecutar una clase de Java que ejecuta un cmdlet de PowerShell utilizando Runtime
Crear, compilar y ejecutar una clase de Java que ejecuta un cmdlet de PowerShell utilizando Runtime import java.io.*; public class CrearJava { public static void main(String[] args) { FileWriter fichero = null; PrintWriter pw = null; try { fichero = new FileWriter("EjecutarPowerShell.java"); pw = new PrintWriter(fichero); pw.println("import java.io.IOException;"); pw.println("import…
View On WordPress
0 notes
jesusninoc · 7 years ago
Text
Ejecutar una clase de Java que ejecuta un cmdlet de PowerShell utilizando Runtime
Tumblr media
Clase de Java que ejecuta PowerShell import java.io.IOException; import java.util.concurrent.TimeUnit; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class EjecutarPowerShell { public static void main(String[] args) throws InterruptedException { Runtime runtime = Runtime.getRuntime(); try { Process process = runtime.exec("powershell.exe…
View On WordPress
0 notes