search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell | No Comment | 3,970 views | 29/01/2016 21:01

This is an example Mime Type script to show you how to get it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Create Content Type Map
$ContentTypeMap = @{
	".jpg"  = "image/jpeg";
	".jpeg" = "image/jpeg";
	".gif"  = "image/gif";
	".png"  = "image/png";
	".tiff" = "image/tiff";
	".zip"  = "application/zip";
	".json" = "application/json";
	".xml"  = "application/xml";
	".rar"  = "application/x-rar-compressed";
	".gzip" = "application/x-gzip";
}
 
$File = Get-ChildItem C:\YourFilePath.json
$FileMimeType = $ContentTypeMap[$File.Extension.ToLower()];
Write-Output $FileMimeType

You can get mime types from IIS.


Posted in Windows Powershell | No Comment | 1,271 views | 23/01/2016 17:38

You can use Test-Path to test if file is exist.

But you can also use [System.IO.File]::Exists() to check it fast.

1
[System.IO.File]::Exists("Your File Path")

You can use in if block to check it on one line:

1
2
3
4
if ([System.IO.File]::Exists("C:\setup.log"))
{
Write-Output "File Exist"
}

It will also use less memory.


Posted in Windows Powershell | No Comment | 1,918 views | 16/01/2016 15:20

You can simply check .NET Core status with following code:

1
2
3
4
5
# Check PSEdition
if ($PSVersionTable.PSEdition -eq "Core")
{
Write-Host "Core Edition";
}

You can check it on Nano server.


Posted in Windows Powershell | No Comment | 1,865 views | 10/01/2016 00:16

Bir değişkenin değerini, dosya içeriğinden aşağıdaki gibi okuyabilirsiniz.

${C:\deneme.txt}

Değişkene aşağıdaki gibi yazdığınızda ise dosya içeriği güncellenir.

${C:\deneme.txt} = "test"

Farklı PowerShell session’larına bu şekilde variable aktarılabilir.