Gorgo.Live.ToString()

Mariusz, Gorzoch tech Blog

Archive for January 2014

Windows 8.1 without password

leave a comment »

Recently I had to setup laptop for my mother and for people her age entering password when logging into the system is quite abstract idea. I had to get rid for it and it comes that it is pretty simple to be do. Just hit Win + R and enter “netplwiz”. This shout open you a dialog box where you can uncheck requirement to enter password on each login. Hit apply and enter your password two times. After that system should log you in automatically without asking for password.

Advertisements

Written by Mariusz Gorzoch

26 January 2014 at 11:00

Posted in Windows8

Changing my site host URL in SharePoint 2013

with one comment

Despite it sound like quite difficult task in reality it is not. You just need to fallow few steps:

1. Go to “Application management” and select “Manage web application”

2. Click on your current “My site web application” and use “Extend” feature

Using that feature causes that this web site will be extended and by this exposed by IIS on additional URL. In my case I’ve extended my old web application “http://internalServer:81” to “http://my.intranet.com” (and of course I registered new name in DNS to be resolved to my server <- but I believe that is obvious)

3. Go to AAM (“Application management” –> “Configure alternate access mappings”) and select (if it is not selected already) your old “My host” web application.

4. Use “Edit public URLs” button

SNAGHTML53925c0

5. Ensure that new URL (in my case “http://my.intranet.com” is a default one <- you will need to swap it with the one with is currently default)

SNAGHTML53a9c53

so, your new “My site host” URL need to be in default and the old one need to go into “Intranet”

6. Go to “Manage profile service” –> “Setup my site”

SNAGHTML53c140f

and adjust “My site host location” to point to new “My site host” URL. Please notice that if you will not perform step 5, then even if you type here new my site host URL, then after saving and coming back system will restore old one <- this is the reason why we need to make new my site host URL a default one (more info around that you can find here : http://sharepoint.stackexchange.com/questions/35756/new-mysite-url-still-redirects-to-old-url )

ok, open your home page and verify if system is using new “My site host” URL. It worked in my case.

Written by Mariusz Gorzoch

23 January 2014 at 14:25

Posted in SharePoint 2013

SQL backup from PowerShell

with one comment

Today I came against a problem of ‘how to perform backup of database from PowerShell’ script. If you start goggling around it then you will find that there are some extensions with are part of SQL 2012 or feature packs with you can add to your installation… but guess what : I just want to do simple backup without putting too much effort and by the way my server is running SQL Express 2008 R2. Lucky this can be resolved be good old ADO. Please find script to do that below:

# Create and open a database connection
$sqlConnection = new-object System.Data.SqlClient.SqlConnection "server=.;database=db;Integrated Security=sspi"
$sqlConnection.Open()
#Create a command object
$tStamp = Get-Date -format yyyy_MM_dd_HHmmss
$sqlCommand = $sqlConnection.CreateCommand()
$sqlCommand.CommandText = "backup database db to disk = ‘c:\backupFolder\db_"+$tStamp+".bak’ with copy_only"
#Execute the Command
$sqlReader = $sqlCommand.ExecuteScalar()
# Close the database connection
$sqlConnection.Close()

Done it and couldn’t be easier

Written by Mariusz Gorzoch

9 January 2014 at 12:23

Posted in Powershell, SQL

Upload of files to FTPS from PowerShell

leave a comment »

Recently I’ve updated my PowersShell script to upload files to FTPS (FTP over SSL) server. Below you can find that script. Most important change in comparison to previous one is around the way I read and send data. In previous version this was done thru read of entire file into memory and then just sent it from the buffer. That of course could cause problems in case of large files. New approached uses small buffer (=4096) and send that in peace’s. To find more details about that script please refer to my previous post

[Net.ServicePointManager]::ServerCertificateValidationCallback={$true}
$Dir = "D:\FolderWithBackupFilesToMove"
foreach($item in (dir $dir))
{
    write-output "————————————–"
    $fileName = $item.FullName
    write-output $fileName
    $ftp = [System.Net.FtpWebRequest]::Create("ftp://some.ftp.server.com/someRootFolder/"+$item.Name)
    $ftp = [System.Net.FtpWebRequest]$ftp
    $ftp.UsePassive = $true
    $ftp.UseBinary = $true
    $ftp.EnableSsl = $true
    $ftp.Credentials = new-object System.Net.NetworkCredential("UserName","Password")
    $ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
    $rs = $ftp.GetRequestStream()
   
    $reader = New-Object System.IO.FileStream ($fileName, [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::Read)
    [byte[]]$buffer = new-object byte[] 4096
    [int]$count = 0
    do
    {
        $count = $reader.Read($buffer, 0, $buffer.Length)
        $rs.Write($buffer,0,$count)
    } while ($count -gt 0)
    $reader.Close()
    $rs.Close()
    write-output "+transfer completed"
   
    $item.Delete()
    write-output "+file deleted"
}

have fun

Written by Mariusz Gorzoch

7 January 2014 at 11:07

Posted in Powershell