logo
down
shadow

Update IIS 6 WebSite Credentials via powershell


Update IIS 6 WebSite Credentials via powershell

By : Dovail
Date : November 22 2020, 10:31 AM
it should still fix some issue Ugh, finally found a command that works. All in all I've tried 4 different variation of the same thing from different example around the interwebz, all of which only work the first time. But this command updates properly on subsequent changes:
code :
function Set-Site-Credentials(
    $SiteElement,
    $Credentials
){  
    Set-WebConfiguration -Filter "$($SiteElement.ItemXPath)/application[@path='/']/virtualDirectory[@path='/']" -Value @{userName="$($Credentials.Domain)\$($Credentials.UserName)"; password="$($Credentials.Password)"}    
}
param (
    [switch]$All,
    [switch]$AllPools,
    [switch]$AllSites,
    [string]$AppPool,
    [string]$Site 
)

Import-Module WebAdministration

function Set-AppPool-Credentials(
    $AppPoolElement,
    $Credentials
){
    Set-ItemProperty $AppPoolElement.PSPath -name processModel -value @{userName="$($Credentials.Domain)\$($Credentials.UserName)";password="$($Credentials.Password)";identitytype=3}
}

function Set-Site-Credentials(
    $SiteElement,
    $Credentials
){  
    Set-WebConfiguration -Filter "$($SiteElement.ItemXPath)/application[@path='/']/virtualDirectory[@path='/']" -Value @{userName="$($Credentials.Domain)\$($Credentials.UserName)"; password="$($Credentials.Password)"}    
}

$newCredentials = (Get-Credential).GetNetworkCredential()

$appPools = Get-ChildItem IIS:\AppPools
$sites = Get-ChildItem IIS:\Sites


if($All -or $AllPools){
    $appPools | Foreach-Object { Set-AppPool-Credentials -AppPoolElement $_ -Credentials $newCredentials }
}
elseif($AppPool){
    $poolElement = ($appPools | Where-Object { $_.name -eq $AppPool })
    Set-AppPool-Credentials -AppPoolElement $poolElement -Credentials $newCredentials
}

if($All -or $AllSites){
    $sites | Foreach-Object { Set-Site-Credentials -SiteElement $_ -Credentials $newCredentials }
}
elseif($Site){
    $siteElement = ($sites | Where-Object { $_.name -eq $Site })
    Set-Site-Credentials -SiteElement $siteElement -Credentials $newCredentials
}

Restart-Service W3SVC


Share : facebook icon twitter icon
Powershell Website credentials help

Powershell Website credentials help


By : user3173136
Date : March 29 2020, 07:55 AM
hop of those help? If you're running Windows 7 or Windows Server 2008 R2 you should have the IIS Administration Cmdlets available to use. If you need to load the module type Import-Module WebAdministration then type Get-Command WebAdministration\* to see all the commands. You'll want to check out the cmdlet docs I linked below for specifics.
Web Server (IIS) Administration Cmdlets in Windows PowerShell
Update Azure Website instance size (Small, Medium, Large) with Powershell

Update Azure Website instance size (Small, Medium, Large) with Powershell


By : user2724867
Date : March 29 2020, 07:55 AM
will be helpful for those in need Yes, you first need to know the name of the Resource Group and Web Hosting Plan to which your website belongs, which you can get from the new Azure Portal. Then you can change the worker size to 0 (Small), 1 (Medium) or 2 (Large).
code :
Switch-AzureMode AzureResourceManager

$resourceGroup = "MyResourceGroup"
$webHostingPlan = "MyWebHostingPlan"

$whp = Get-AzureResource `
    -Name $webHostingPlan `
    -ResourceGroupName $resourceGroup `
    -ResourceType "Microsoft.Web/serverFarms" `
    -ApiVersion 2014-04-01

$newWorkerSize = 1
$whp.Properties.workerSize = $newWorkerSize
$whp.Properties.workerSizeId = $newWorkerSize

Set-AzureResource `
    -Name $webHostingPlan `
    -ResourceGroupName $resourceGroup `
    -ResourceType "Microsoft.Web/serverFarms" `
    -ApiVersion 2014-04-01 `
    -PropertyObject $whp.Properties
Retrieve Credentials from Windows generic Credentials Store using C# in ASP.net website under IIS

Retrieve Credentials from Windows generic Credentials Store using C# in ASP.net website under IIS


By : George Tiser
Date : March 29 2020, 07:55 AM
Does that help You should switch "Load User Profile" parameter of IIS App Pool to true. Then your code should start working.
Set SQL Server credentials in PowerShell script or invoke with credentials

Set SQL Server credentials in PowerShell script or invoke with credentials


By : Dennis van der Graaf
Date : March 29 2020, 07:55 AM
this one helps. Below is my working PowerShell script for connecting to AWS SQL Server database. How can I set the credentials hard coded with in the script without the prompt or invoke the script with the credentials?
code :
    $SQLInstance = "Instance Name"
    $Database = "Database"
    $ID = "User ID" 
    $Password = "Password"

function Invoke-Sqlcommand 
{ 
    [CmdletBinding()] 
    param( 
    [Parameter(Position=0, Mandatory=$true)] [string]$ServerInstance, 
    [Parameter(Position=1, Mandatory=$false)] [string]$Database, 
    [Parameter(Position=2, Mandatory=$false)] [string]$Query, 
    [Parameter(Position=3, Mandatory=$false)] [string]$Username, 
    [Parameter(Position=4, Mandatory=$false)] [string]$Password, 
    [Parameter(Position=5, Mandatory=$false)] [Int32]$QueryTimeout=600, 
    [Parameter(Position=6, Mandatory=$false)] [Int32]$ConnectionTimeout=15, 
    [Parameter(Position=7, Mandatory=$false)] [ValidateScript({test-path $_})] [string]$InputFile, 
    [Parameter(Position=8, Mandatory=$false)] [ValidateSet("DataSet", "DataTable", "DataRow")] [string]$As="DataRow" 
    ) 

    if ($InputFile) 
    { 
        $filePath = $(resolve-path $InputFile).path 
        $Query =  [System.IO.File]::ReadAllText("$filePath") 
    } 

    $conn=new-object System.Data.SqlClient.SQLConnection 

    if ($Username) 
    { $ConnectionString = "Server={0};Database={1};User ID={2};Password={3};Trusted_Connection=False;Connect Timeout={4}" -f $ServerInstance,$Database,$Username,$Password,$ConnectionTimeout } 
    else 
    { $ConnectionString = "Server={0};Database={1};Integrated Security=True;Connect Timeout={2}" -f $ServerInstance,$Database,$ConnectionTimeout } 

    $conn.ConnectionString=$ConnectionString 

    #Following EventHandler is used for PRINT and RAISERROR T-SQL statements. Executed when -Verbose parameter specified by caller 
    if ($PSBoundParameters.Verbose) 
    { 
        $conn.FireInfoMessageEventOnUserErrors=$true 
        $handler = [System.Data.SqlClient.SqlInfoMessageEventHandler] {Write-Verbose "$($_)"} 
        $conn.add_InfoMessage($handler) 
    } 

    $conn.Open() 
    $cmd=new-object system.Data.SqlClient.SqlCommand($Query,$conn) 
    $cmd.CommandTimeout=$QueryTimeout 
    $ds=New-Object system.Data.DataSet 
    $da=New-Object system.Data.SqlClient.SqlDataAdapter($cmd) 
    [void]$da.fill($ds) 
    $conn.Close() 
    switch ($As) 
    { 
        'DataSet'   { Write-Output ($ds) } 
        'DataTable' { Write-Output ($ds.Tables) } 
        'DataRow'   { Write-Output ($ds.Tables[0]) } 
    } 

} 


Invoke-Sqlcommand -ServerInstance $SQLInstance -Database $Database -Query "Query Goes here" -Username $ID -Password $Password
How to set an IIS Website's Physical Path credentials through Powershell?

How to set an IIS Website's Physical Path credentials through Powershell?


By : user2553796
Date : March 29 2020, 07:55 AM
I wish this help you How can I set the IIS 10.0 Website's Physical Path Credentials through Powershell? , You could use the following Powershell commands :
code :
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='site1']/application[@path='/']/virtualDirectory[@path='/']" -name "userName" -value "jalpa"

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='site1']/application[@path='/']/virtualDirectory[@path='/']" -name "password" -value "aStrongPassword"

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='site1']/application[@path='/']/virtualDirectory[@path='/']" -name "logonMethod" -value "ClearText"
Related Posts Related Posts :
  • Malware Using .Lnk file to Powershell
  • Powershell Foreach-Object Foreach loop read string from several files and write to one
  • Method Invocation failed system.string error
  • Script to move folders with specific names and characters
  • Azure blob download is incredibly slow using PowerShell (via Get-AzureStorageBlobContent), but fast via Azure Explorer,
  • Is there a way in Powershell to append or prepend the value of a variable to the output of a piplined command
  • How do I pass raw strings to commands through the command line in PowerShell?
  • Converting Get-ChildItem output to string[]
  • Compress-Archive powershell command not known in windows 7
  • Adding a newline (line break) to a Powershell script
  • Import-Csv of huge (13M Rows) filtered using Where-Object with 11k rows
  • Trouble with Expanding $Env:TEMP in start-process MSIEXEC
  • 'New-AzureStorageContext' is not recognized
  • How can I set the Cache-Control when using Write-S3Object?
  • Powershell script not exiting while running via freeSSHd
  • Dot Source a "script" within a Function
  • Powershell script to create website in IIS
  • Change initial directory in windows powershell
  • Launching Internet Explorer from a PowerShell script
  • How to call .cmd file as administrator?
  • Task Scheduler with powershell not working
  • Error connecting to Azure VM with VS Online Build Server / Release Management
  • PowerShell grab plaintext from URL and use as variable
  • How to extract exe file without installing it, using powershell?
  • How to quickly check if WMI information can be pulled from a remote computer
  • Putting a specific Powershell Get-Counter Statistic into a variable
  • Nonewline messes up output for Powershell
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org