Quantcast
Channel: Windows PowerShell forum
Viewing all 21975 articles
Browse latest View live

Export to csv

$
0
0

I am trying to run a script and export the results to csv. The script runs fine onscreen but when the output is sent to the csv file the results for msDS-PrimaryComputer all return "Microsoft.ActiveDirectory.Management.ADPropertyValueCollection".

Here is the script I am running:

Get-ADUser -Filter * -Properties * | Select Name,sAMAccountName,msDS-PrimaryComputer | Export-Csv 'c:\Temp\ADUserPrimaryComputer.csv' -NoTypeInformation
Get-Content "C:\Temp\ADUserPrimaryComputer.csv"

The output is fine on screen but not in the csv file. From my research I gather that this is due to msDS-PrimaryComputer containing a list of values but not being familiar with scripting, I haven't been able to figure out how to make it work. Here is the code I used with -Expand

Get-ADUser -Filter * -Properties * |
    Select -Expand msDS-PrimaryComputer
Get-ADUser -Filter * -Properties * |
    Name,sAMAccountName,@{N='msDS-PrimaryComputer';E={$_.msDS-PrimaryComputer -join '|'}} |
    Export-Csv 'c:\Temp\ADUserPrimaryComputer.csv' -NoTypeInformation
Get-Content "C:\Temp\ADUserPrimaryComputer.csv"

Thanks in advance for any help you can provide.


parseexact

$
0
0

Hi,

I would like converting a registry value to datetime.

In the registry, the value is: 08/20/2019 13:18:50

With get-date, I get: 20 août 2019 15:30:57

$test = '08/20/2019 13:18:50'
[datetime]::parseexact($test, 'yyyy-MM-dd HH:mm:SS', $null)
 

And then I get 

Exception lors de l'appel de « ParseExact » avec « 3 » argument(s) : « La chaîne n'a pas été reconnue en tant que DateTime valide. »
Au caractère Ligne:2 : 1
+ [datetime]::parseexact($test, 'yyyy-MM-dd HH:mm:SS', $null)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FormatException

Invalid datetime...

I need comparing the date time from the registry with the current date time and see if its bigger than 30 days.

Any idea?


For-Each Get-ADPrincipalGroupMembership - Get Computer Name to Export-CSV

$
0
0

How would i to get the AD security group name and the computer name for each on my spreadsheet. 

Right now I am only getting the group. Need the Computer Name. 

$Get2008s = "TEXTFILEPATHHERE"

 Get-Content $Get2008s | ForEach-Object { 

    Get-ADPrincipalGroupMembership (Get-ADComputer $_) | select name | Where-Object {$_.name -like '*SCCM*' } | Sort Name

    } | 
Export-Csv "FILEPATHHERE" -NoTypeInformation -UseCulture

ProviderName - Empty - win32_mappedlogicaldisk -

$
0
0

Group

    What could be happening that the ProviderName is coming empty, the drive is mapped and I can even delete process and other mappings of the mapped drive?

$ComputerName = "FGAND_COBRANCA"

gwmi win32_mappedlogicaldisk -ComputerName $ComputerName | select SystemName,Name,ProviderName,SessionID | foreach { 
 $disk = $_
 $user = gwmi Win32_LoggedOnUser -ComputerName $ComputerName | where { ($_.Dependent.split("=")[-1] -replace '"') -eq $disk.SessionID} | foreach {$_.Antecedent.split("=")[-1] -replace '"'}
 $disk | select *,@{n="MappedTo";e={$user}}
}



SystemName   : FGAND_COBRANCA
Name         : Q:
ProviderName :
SessionID    : 116042600
MappedTo     : user_cont.projeto


Using Add-Member and Export-CSV with a foreach statement will not update a CSV file properly

$
0
0

Hi all,

I'm working on a part of a script that collects the Monitors and their respective Serial Numbers attached to a computer and export it to a CSV file. Since I won't know the number of monitors attached to every system, I am using a foreach statement to collect all the monitors.

The problem is the CSV file won't update correctly. If I run the script on a computer with one monitor, the CSV file will show "Monitor 1" and "Monitor 1 Serial Number". If I run the script on a computer with two monitors and have it output to the same CSV file, it will only show "Monitor 1" and "Monitor 1 Serial Number", however I am expecting it to add "Monitor 2" and "Monitor 2 Serial Number". Can anyone offer some suggestions? Here's my script so far:

# Get monitor info
$MonitorNumber = 0
$MonitorCounter1 = -3
$MonitorCounter2 = -2
$MonitorCounter3 = -1
$Monitors = Get-WmiObject -Namespace "root\WMI" -Class "WMIMonitorID"

function GetMonitorInfo {
  foreach ($Monitor in $Monitors) {
    ([System.Text.Encoding]::ASCII.GetString($Monitor.ManufacturerName)).Replace("$([char]0x0000)","")
    ([System.Text.Encoding]::ASCII.GetString($Monitor.UserFriendlyName)).Replace("$([char]0x0000)","")
    ([System.Text.Encoding]::ASCII.GetString($Monitor.SerialNumberID)).Replace("$([char]0x0000)","")

  }
}

# CSV properties
$infoObject = New-Object PSObject

foreach ($Monitor in $Monitors) {
  $MonitorNumber++
  $MonitorCounter1 = $MonitorCounter1 + 3
  $MonitorCounter2 = $MonitorCounter2 + 3
  $MonitorCounter3 = $MonitorCounter3 + 3
  $Monitor = GetMonitorInfo | Select-Object -Index $MonitorCounter1,$MonitorCounter2
  $MonitorSN = GetMonitorInfo | Select-Object -Index $MonitorCounter3
  $Monitor = $Monitor -join ' '
  Add-Member -InputObject $infoObject -MemberType NoteProperty -Name "Monitor $MonitorNumber" -Value $Monitor -Force
  Add-Member -InputObject $infoObject -MemberType NoteProperty -Name "Monitor $MonitorNumber Serial Number" -Value $MonitorSN -Force
}

$infoObject
$infoColl += $infoObject

# Export info to CSV file
try {
  $infoColl | Export-Csv -Path "$pwd\Monitors.csv" -NoTypeInformation -Append -Force
  Write-Host -ForegroundColor Green "Inventory was successfully updated!"
  exit 0
}
catch {
}
throw "Unable to export to the CSV file. Please check the permissions on the file."

Thank you!!!

Windows Powershell through Jenkins

$
0
0

Hi ,

Please help me for resolving this : I need to run this script on Remote machine through Jenkins. Please re arrange this and help me.

$newline = @()

 

[Array]$computernames = $env:computernames

 

$computernames = $computernames.trim()

 

$computernames1 = $computernames -split "`n`r|`r |`n"

 

foreach($computer in $computernames1) {

#Write-host "My selected computer is $computer"

 

Start-Process powershell -Verb runAs

$result =Stop-Service healthservice

Stop-Service wuauserv

ren C:\Windows\SoftwareDistribution SoftwareDistribution.old

Start-Service wuauserv

$newline += $result

 

}

error on all commands "Set-Location : The term 'Set-Location' is not recognized as the name of a cmdlet"

$
0
0

HI

I am getting error on all commands executing in Windows Powershell (even CD\ command) below is the error:

Set-Location : The term 'Set-Location' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Set-Location \
+ ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Set-Location:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

please help to resolve issue

Extract characters from txt

$
0
0

Hello, I am new to powershell and I need to grab a certain part of a text from .txt file as:

ip         location                                                                                                                      
--         --------                                                                                                                      
75.82.30.5 @{country=RO; region=Bucuresti; city=Bucharest; lat=44.4354; lng=26.1033; postalCode=051527; timezone=+03:00; geonameId=683506}

I need to grab RO part and make it a variable in order to used further 

I have this as a code:

New-Item -ItemType directory -Path C:\temp\
cd C:\temp\
Invoke-RestMethod -Method Get -Uri "https://geo.ipify.org/api/v1?apiKey=at_iNhGwrCTwXtgrIVk7wborCRQMpH5Q&ipAddress" > C:\temp\country.txt
$Text = Get-Content -Path C:\temp\country.txt

The project is to rename computer based on IP location + Serial number 

Thank you


Variable Issue

$
0
0

Sort of new to powershell and having an issue with the below:

Get-AppxPackage -AllUsers *Microsoft.Bing* | Export-CSV K:\Package.csv
$Package = Import-Csv "\\ks-appsrv-02\apps$\Package.csv" | Select -ExpandProperty PackageFullName
Remove-AppxProvisionedPackage -Online -PackageName $Package

The first line creates a CSV with any Microsoft AppX package in it containing Microsoft.Bing in the name

The second line gets the full package name (In this case Microsoft.BingWeather_4.31.11905.0_x64__8wekyb3d8bbwe) and assigns it against the variable $Package

Now the 3rd line should remove the package but I am getting:

Remove-AppxProvisionedPackage : The system cannot find the file specified.
At line:1 char:103
+ ... FullName} | Remove-AppxProvisionedPackage -Online -PackageName $Packa ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Remove-AppxProvisionedPackage], COMException
    + FullyQualifiedErrorId : Microsoft.Dism.Commands.RemoveAppxProvisionedPackageCommand

If I just ran it as Remove-AppxProvisionedPackage -Online -PackageName Microsoft.BingWeather_4.31.11905.0_x64__8wekyb3d8bbwe it would work so I'm not sure what I'm doing wrong here.

All help is greatly appreciated.

Using variables for the arguments in the Grant-SMBShareAccess cmdlet

$
0
0

The variable for the share was evaluated but the value of the variable represented by the share permissions was not. Is there a way to evaluate its value?

 Grant-SmbShareAccess -Name $SHARE -AccessRight Read -AccountName $SHARERead
Grant-SmbShareAccess : Cannot validate argument on parameter 'Name'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At line:1 char:36+         Grant-SmbShareAccess -Name $SHARE -AccessRight Read -AccountN ...+                                    ~~~~~~+ CategoryInfo          : InvalidData: (:) [Grant-SmbShareAccess], ParameterBindingValidationException+ FullyQualifiedErrorId : ParameterArgumentValidationError,Grant-SmbShareAccess


Using Set-QADComputer for multiple computers in column A with properties in Column B

$
0
0

Currently using a script to set a property on a single computer works well, but now I have a list I need to set and do not have the time to do it manually for each one. Any help on a foreach and/or loop script would be helpful.

Single line script: *disregard "property" and "objectprop"

function set-"Property" {
$computer= Read-Host "Computer name"
$"Property" = Read-Host "'Property'"
Set-QADComputer -Identity $computer -ObjectAttributes @{"objectprop" = $"property"} -Proxy

Get-QADComputer $computer -IncludedProperties "objectprop" |select name, "objectprop"
}

I have an excel file with the computer in 1 column and the corresponding property needing to be set in another column.

Any help/advice greatly appreciated

How can I pass the rename-computer credential in a powershell script (.ps1)?

$
0
0

Hello everyone,

How can i give the password to "rename-computer" for the "-domaincredential" attribute in the powershell script,?

There are no properties/methods like "-password" (eg image)

I want the script to execute silently, the without HAVING to Manually The Enter password that Needs to be encrypted.

I have read the links below,  but still confused How to Write the completely command in .ps1
: HTTPS: //stackoverflow.com/questions/23482389 /entering-a -password-for-domaincredential-in-rename-computer -in-powershell?Noredirect = 1&lq = 1
https://stackoverflow.com/questions/13842611/how-to-pass-credentials-to-rename- Command

I wrote the following, but it n't work to rename my computer name.

$path=\\sc\cont
$computername="CN-D"+$number
$currentname=(Get-CimInstance -ClassName Win32_ComputerSystem).Name
$user="sc\joindomain"
$encpwd = Get-Content $path\password.bin
$passwd = ConvertTo-SecureString $encpwd
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $passwd
if($computername -ne $currentname){
    Rename-Computer -NewName $computername -DomainCredential $credential
}

Thank you in advance.

How to stop getting prompted to "Confirm"

$
0
0

Hello,

I have some Windows Server 2008 systems that I'm trying to run a powershell script on to delete some temp files, but I keep getting prompted with "Confirm... Y [Yes] [A] Yes to All...... ect"  Is there a way to bypass the Confirm?

Thanks,

Tom


Tom Martin Email: tmartin@caa.com

Move-Item using a file of destinations

$
0
0
I have a bunch of files I need to move from 1 source to multiple destinations. I have a file with the destination paths, but I can't seem to figure out how to use the file and get the items in the correct folder. Can anyone help? Thank you. 

Set-ADObject $guid -Replace issue

$
0
0

Hello all!

Kindly please for help - I have strange issue with PS script.

Here is a small summary what it does: it creates CSV file from shared drive, update SQL database and when it is done it updates Active Directory user objects with attributes valuses from CSV such as position, lastname, firstname, department, manager etc.

Due to unknown reason, some AD objects cannot be updated due to error message:

Set-ADObject : replace
At D:\TETA_IMPORT\TEST\sqlinject-test.ps1:183 char:1
+ Set-ADObject $guid -Replace @{
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (c5dce716-4965-4360-8e89-f82517e8f512:ADObject) [Set-ADObject], ADInvalidOperationException
    + FullyQualifiedErrorId : ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.SetADObject

The full code is below:

Import-module ActiveDirectory

#Start-Transcript -path D:\HR\log-file.txt

Copy-Item \\domain.com\shared_drive\file\data_file.CSV D:\shared_drive\data_file.CSV -Force

$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server=server01.domain.com;Database=YARIS;Integrated Security=False;uid=Awaw00dbs0001Yaris;pwd=p@sswd2!"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = "truncate table GSE_DANE"
$SqlCmd.Connection = $SqlConnection

$SqlConnection.Open()
$SqlCmd.ExecuteNonQuery() 
$SqlConnection.Close()

#################################################### 
# 
# PowerShell CSV to SQL Import Script 
# 
#################################################### 
 
# Database variables 
$sqlserver = "database_serv.domain.com" 
$database = "Yaris" 
$table = "GSE_DANE" 
# CSV variables 
$csvfile = "D:\shared_drive\data_file.CSV" 
$csvdelimiter = "`t" 
$FirstRowColumnNames = $true 
################### No need to modify anything below ################### 
Write-Host "Script started..." 
$elapsed = [System.Diagnostics.Stopwatch]::StartNew()  
[void][Reflection.Assembly]::LoadWithPartialName("System.Data") 
[void][Reflection.Assembly]::LoadWithPartialName("System.Data.SqlClient") 
# 50k worked fastest and kept memory usage to a minimum 
$batchsize = 50000 
# Build the sqlbulkcopy connection, and set the timeout to infinite 
$connectionstring = "Data Source=$sqlserver;Initial Catalog=$database;uid=Awaw00dbs0001Yaris;pwd=p@sswd2!" 
$bulkcopy = New-Object Data.SqlClient.SqlBulkCopy($connectionstring, [System.Data.SqlClient.SqlBulkCopyOptions]::TableLock) 
$bulkcopy.DestinationTableName = $table 
$bulkcopy.bulkcopyTimeout = 0 
$bulkcopy.batchsize = $batchsize 
# Create the datatable, and autogenerate the columns. 
$datatable = New-Object System.Data.DataTable 
# Open the text file from disk 
$reader = New-Object System.IO.StreamReader($csvfile) 
$columns = (Get-Content $csvfile -First 1).Split($csvdelimiter) 
if ($FirstRowColumnNames -eq $true) { $null = $reader.readLine() } 
foreach ($column in $columns) {  
    $null = $datatable.Columns.Add() 
} 
# Read in the data, line by line, not column by column 
while (($line = $reader.ReadLine()) -ne $null)  { 
    $null = $datatable.Rows.Add($line.Split($csvdelimiter)) 
# Import and empty the datatable before it starts taking up too much RAM, but  
# after it has enough rows to make the import efficient. 
    $i++; if (($i % $batchsize) -eq 0) {  
        $bulkcopy.WriteToServer($datatable)  
        Write-Host "$i rows have been inserted in $($elapsed.Elapsed.ToString())." 
        $datatable.Clear()  
    }  
}  
# Add in all the remaining rows since the last clear 
if($datatable.Rows.Count -gt 0) { 
    $bulkcopy.WriteToServer($datatable) 
    $datatable.Clear() 
} 
# Clean Up 
$reader.Close(); $reader.Dispose() 
$bulkcopy.Close(); $bulkcopy.Dispose() 
$datatable.Dispose() 
Write-Host "Script complete. $i rows have been inserted into the database." 
Write-Host "Total Elapsed Time: $($elapsed.Elapsed.ToString())" 
# Sometimes the Garbage Collector takes too long to clear the huge datatable. 
[System.GC]::Collect()

Echo "***********************Starting Import******************************************************************************"
$A = Get-Date
$A.ToUniversalTime()
echo $A

$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server=database_serv.domain.com;Database=YARIS;Integrated Security=False;uid=Awaw00dbs0001Yaris;pwd=p@sswd2!"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand

$SqlCmd.CommandText = "SELECT * from GSE_DANE"

$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$DataSet.Tables[0] | foreach {

$suplogin = 0
$arr = @($_.LOGIN.split('\/'))

if ($arr[0]) {
if ($arr[0] -notlike "domain") {}
else {
$guid = (Get-ADUser $arr[1]).objectGuid

#echo $_.EP15
#$arr2 = @($_.EP3.split('\/'))

        $UserNameToFind=$_.SUPERIOR_ID
        $connectionstring2="Server=database_serv.mednet.world;Database=YARIS;Integrated Security=False;uid=Awaw00dbs0001Yaris;pwd=p@sswd2!"
        $SQLCommandText2="SELECT LOGIN FROM GSE_DANE WHERE USER_ID='$($UserNameToFind)'"
        #$SQLCommandText2="SELECT LOGIN FROM GSE_DANE WHERE login like 'mednet\wojciecp'"
        $SQLConnection2 = new-object system.data.sqlclient.SqlConnection($connectionstring)
        $SQLConnection2.open()
        $sqlCommand2 = New-Object system.Data.sqlclient.SqlCommand($SQLCommandText2,$SQLConnection2)
        $suplogin = $sqlCommand2.ExecuteScalar()
        $SQLConnection2.close()
        if ($suplogin) {
        $arr2 = @($suplogin.split('\/'))
        if ($arr2[0]) {
if ($arr2[0] -notlike "domain") {$dnsup=$null}
else {
$dnsup =(Get-AdUser $arr2[1] | select DistinguishedName)
}
echo $_.LOGIN
echo $suplogin
echo $guid
echo $dnsup.DistinguishedName

if ($dnsup.DistinguishedName) {

Set-ADObject $guid -Replace @{

'physicalDeliveryOfficeName'=$_.COMPANY;
#'telephoneNumber'=$telephoneNumber;
'department'=$_.DEPARTMENT;
'description'=$_.STANOWISKO;
'title'=$_.JOB_POSITION;
'streetAddress'=$_.OFFICE_ADDRESS;
'c'="EN";
'co'=$_.COUNTRY;
'company'=$_.DIVISION;
'manager'=$dnsup.DistinguishedName;
'ipPhone'=$_.USER_ID;
'pager'=$_.CC;


} -Partition "DC=mednet,DC=world"

}


#echo $_.IP1,$_.IP3,$dnsup


}


}

else {

echo $_.LOGIN
#echo $suplogin
#echo $guid


echo $dnsup.DistinguishedName


Set-ADObject $guid -Replace @{

'physicalDeliveryOfficeName'=$_.COMPANY;
#'telephoneNumber'=$telephoneNumber;
'department'=$_.DEPARTMENT;
'description'=$_.STANOWISKO;
'title'=$_.JOB_POSITION;
'streetAddress'=$_.OFFICE_ADDRESS;
'c'="EN";
'co'=$_.COUNTRY;
'company'=$_.DIVISION;
#'manager'=$dnsup.DistinguishedName;
'ipPhone'=$_.USER_ID;
'pager'=$_.CC;

} -Partition "DC=domain,DC=com"

}

}
}
}




Getting files older than and then copying only those

$
0
0

Hi all

I am trying to list all files that have not been in use for x number of days and then copy only those files from the original folder to one set by me. 

$CutoffTime = (Get-Date).AddDays(-825)
$files = Get-ChildItem  -Recurse  -Path "Folder Path" | Where-Object { $_.LastAccessTime -le "$CutoffTime" } | Select-Object FullName | out-string 
foreach ($file in $files){

Copy-Item -literalpath $file -Destination "destination Path"

}


i have also tried the copy job with just the -path in copy-item. 

Each time i try this solution i get the below error:

Copy-Item : Cannot find drive. A drive with the name '
O' does not exist.
At line:5 char:1+ Copy-Item -literalpath $file -Destination (my path) ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : ObjectNotFound: (
O:String) [Copy-Item], DriveNotFoundException+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.CopyItemCommand

For the life of me i cannot figure out what i am doing wrong. Also ideally i would like it to copy the folder structure. 

Thank you all kindly in advance for any assistance. 

Regards

K


Msft_Volume results: multiple records for 'D:'

$
0
0

Hello, Im getting some strange results for Msft_Volume query

Get-WmiObject -Query "SELECT * FROM Msft_Volume"  -Namespace Root/Microsoft/Windows/Storage

I see 'D' drive six times! I there any explanation and which one is real?

__GENUS              : 2
__CLASS              : MSFT_Volume
__SUPERCLASS         : MSFT_StorageObject
__DYNASTY            : MSFT_StorageObject
__RELPATH            : MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{0074c0a4-0000-0000-0000-100000000000}\\\""
__PROPERTY_COUNT     : 18
__DERIVATION         : {MSFT_StorageObject}
__SERVER             : DELL590HV12
__NAMESPACE          : Root\Microsoft\Windows\Storage
__PATH               : \\DELL590HV12\Root\Microsoft\Windows\Storage:MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{0074c0a4-0000-0000-0000-1000000
                       00000}\\\""
AllocationUnitSize   : 4096
DedupMode            : 4
DriveLetter          : D
DriveType            : 3
FileSystem           : NTFS
FileSystemLabel      : DATA
FileSystemType       : 14
HealthStatus         : 0
ObjectId             : {1}\\DELLCSPRHV02\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\?\Volume{0074c0a4-0000-0000-0000-100000000000}\"
OperationalStatus    : {2}
PassThroughClass     :
PassThroughIds       :
PassThroughNamespace :
PassThroughServer    :
Path                 : \\?\Volume{0074c0a4-0000-0000-0000-100000000000}\
Size                 : 162522984448
SizeRemaining        : 48756031488
UniqueId             : \\?\Volume{0074c0a4-0000-0000-0000-100000000000}\
PSComputerName       : DELL590HV12


__GENUS              : 2
__CLASS              : MSFT_Volume
__SUPERCLASS         : MSFT_StorageObject
__DYNASTY            : MSFT_StorageObject
__RELPATH            : MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{2d4b4fad-0000-0000-0000-100000000000}\\\""
__PROPERTY_COUNT     : 18
__DERIVATION         : {MSFT_StorageObject}
__SERVER             : DELL590HV12
__NAMESPACE          : Root\Microsoft\Windows\Storage
__PATH               : \\DELL590HV12\Root\Microsoft\Windows\Storage:MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{2d4b4fad-0000-0000-0000-1000000
                       00000}\\\""
AllocationUnitSize   : 4096
DedupMode            : 4
DriveLetter          : D
DriveType            : 3
FileSystem           : NTFS
FileSystemLabel      : DATA
FileSystemType       : 14
HealthStatus         : 0
ObjectId             : {1}\\DELLCSPRHV02\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\?\Volume{2d4b4fad-0000-0000-0000-100000000000}\"
OperationalStatus    : {2}
PassThroughClass     :
PassThroughIds       :
PassThroughNamespace :
PassThroughServer    :
Path                 : \\?\Volume{2d4b4fad-0000-0000-0000-100000000000}\
Size                 : 162522984448
SizeRemaining        : 128554635264
UniqueId             : \\?\Volume{2d4b4fad-0000-0000-0000-100000000000}\
PSComputerName       : DELL590HV12


__GENUS              : 2
__CLASS              : MSFT_Volume
__SUPERCLASS         : MSFT_StorageObject
__DYNASTY            : MSFT_StorageObject
__RELPATH            : MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{4491b922-0000-0000-0000-100000000000}\\\""
__PROPERTY_COUNT     : 18
__DERIVATION         : {MSFT_StorageObject}
__SERVER             : DELL590HV12
__NAMESPACE          : Root\Microsoft\Windows\Storage
__PATH               : \\DELL590HV12\Root\Microsoft\Windows\Storage:MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{4491b922-0000-0000-0000-1000000
                       00000}\\\""
AllocationUnitSize   : 4096
DedupMode            : 4
DriveLetter          : D
DriveType            : 3
FileSystem           : NTFS
FileSystemLabel      : DATA
FileSystemType       : 14
HealthStatus         : 0
ObjectId             : {1}\\DELLCSPRHV02\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\?\Volume{4491b922-0000-0000-0000-100000000000}\"
OperationalStatus    : {2}
PassThroughClass     :
PassThroughIds       :
PassThroughNamespace :
PassThroughServer    :
Path                 : \\?\Volume{4491b922-0000-0000-0000-100000000000}\
Size                 : 162522984448
SizeRemaining        : 50788323328
UniqueId             : \\?\Volume{4491b922-0000-0000-0000-100000000000}\
PSComputerName       : DELL590HV12

__GENUS              : 2
__CLASS              : MSFT_Volume
__SUPERCLASS         : MSFT_StorageObject
__DYNASTY            : MSFT_StorageObject
__RELPATH            : MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{95162798-0000-0000-0000-100000000000}\\\""
__PROPERTY_COUNT     : 18
__DERIVATION         : {MSFT_StorageObject}
__SERVER             : DELL590HV12
__NAMESPACE          : Root\Microsoft\Windows\Storage
__PATH               : \\DELL590HV12\Root\Microsoft\Windows\Storage:MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{95162798-0000-0000-0000-1000000
                       00000}\\\""
AllocationUnitSize   : 4096
DedupMode            : 4
DriveLetter          : D
DriveType            : 3
FileSystem           : NTFS
FileSystemLabel      : DATA
FileSystemType       : 14
HealthStatus         : 0
ObjectId             : {1}\\DELLCSPRHV02\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\?\Volume{95162798-0000-0000-0000-100000000000}\"
OperationalStatus    : {2}
PassThroughClass     :
PassThroughIds       :
PassThroughNamespace :
PassThroughServer    :
Path                 : \\?\Volume{95162798-0000-0000-0000-100000000000}\
Size                 : 162522984448
SizeRemaining        : 160064081920
UniqueId             : \\?\Volume{95162798-0000-0000-0000-100000000000}\
PSComputerName       : DELL590HV12

__GENUS              : 2
__CLASS              : MSFT_Volume
__SUPERCLASS         : MSFT_StorageObject
__DYNASTY            : MSFT_StorageObject
__RELPATH            : MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{d2744786-0000-0000-0000-100000000000}\\\""
__PROPERTY_COUNT     : 18
__DERIVATION         : {MSFT_StorageObject}
__SERVER             : DELL590HV12
__NAMESPACE          : Root\Microsoft\Windows\Storage
__PATH               : \\DELL590HV12\Root\Microsoft\Windows\Storage:MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{d2744786-0000-0000-0000-1000000
                       00000}\\\""
AllocationUnitSize   : 4096
DedupMode            : 4
DriveLetter          : D
DriveType            : 3
FileSystem           : NTFS
FileSystemLabel      : New Volume
FileSystemType       : 14
HealthStatus         : 0
ObjectId             : {1}\\DELLCSPRHV02\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\?\Volume{d2744786-0000-0000-0000-100000000000}\"
OperationalStatus    : {2}
PassThroughClass     :
PassThroughIds       :
PassThroughNamespace :
PassThroughServer    :
Path                 : \\?\Volume{d2744786-0000-0000-0000-100000000000}\
Size                 : 162522984448
SizeRemaining        : 139896598528
UniqueId             : \\?\Volume{d2744786-0000-0000-0000-100000000000}\
PSComputerName       : DELL590HV12

__GENUS              : 2
__CLASS              : MSFT_Volume
__SUPERCLASS         : MSFT_StorageObject
__DYNASTY            : MSFT_StorageObject
__RELPATH            : MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{e77f52c6-0000-0000-0000-100000000000}\\\""
__PROPERTY_COUNT     : 18
__DERIVATION         : {MSFT_StorageObject}
__SERVER             : DELL590HV12
__NAMESPACE          : Root\Microsoft\Windows\Storage
__PATH               : \\DELL590HV12\Root\Microsoft\Windows\Storage:MSFT_Volume.ObjectId="{1}\\\\DELLCSPRHV02\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\\\?\\Volume{e77f52c6-0000-0000-0000-1000000
                       00000}\\\""
AllocationUnitSize   : 4096
DedupMode            : 4
DriveLetter          : D
DriveType            : 3
FileSystem           : NTFS
FileSystemLabel      : DATA
FileSystemType       : 14
HealthStatus         : 0
ObjectId             : {1}\\DELLCSPRHV02\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{60fd5c97-6507-4543-99f1-daf47227f21e}:VO:\\?\Volume{e77f52c6-0000-0000-0000-100000000000}\"
OperationalStatus    : {2}
PassThroughClass     :
PassThroughIds       :
PassThroughNamespace :
PassThroughServer    :
Path                 : \\?\Volume{e77f52c6-0000-0000-0000-100000000000}\
Size                 : 162522984448
SizeRemaining        : 46635180032
UniqueId             : \\?\Volume{e77f52c6-0000-0000-0000-100000000000}\
PSComputerName       : DELL590HV12



HOWTO - hunt down all instances of a saved service account username ANYWHERE that it's saved in IIS

$
0
0

Hi

A behemoth of an application which I shan't name (let's call it VoleStrangler for the sake of convenience) has configured a gazillion websites, app pools, virtual directories, COM+ objects, DCOM objects, Scheduled Tasks, entries in config files across multiple application servers... resulting in a massive proliferation of config files and whatnot containing the password for the ONE service account used right across the board.

ALL instances of the account use need to be discovered, in order to ensure that every time the password is updated in AD, every instance of the password in an unmanaged location is refreshed.

I've got rather a lot figured out. I can hunt down COM+ and DCOM objects across the network that are using that service account, and update the passwords. I can also hunt down any scheduled tasks which are using that account. I can even update (some) IIS app pools and virtual directories which are using the service account.

But it's only IIS that is really grinding my gears. I have to explicitly tell PowerShell which paths to search into - and I keep finding objects in IIS that its internal logic simply seems to completely overlook.

Even now I'm looking at 5 subsites which resolutely tell PowerShell that they're not even using the service account for anything - even though the IIS management UI says different. What's even more brilliant is, there doesn't appear to be any way to check which password is configured AND the built-in functions return diddly squat, so the only way to even validate a password rotation is to find the username, get the password, update the password with the new password, and then interrogate the whole ruddy thing all over again just to check that the old password WAS replaced with the new password.

Does anybody out there have a more effective solution i.e. a far more efficient brute force "find any instance of this account being used ANYWHERE in IIS, tell me where you found it, and refresh the password" function?

Because I've been trying for days to build one that'll actually work properly, without any success.

Thanks in advance!


Tim Staddon

identify which network drive was made manually

$
0
0

Hi,

Is it possible with Powershell to identify which drive was not manually from the user instead by login script?

Thanks,

How to check if windows store app is installed

$
0
0

We are dealing with annoying store app where it will install, but doesn't create any shortcuts (via SCCM).

The idea I cam up with is to setup a 2nd copy as a dependency in SCCM so once the install completes a script checks that the store app is there and copies the necessary shortcuts.

I can get the application to show with the command

Get-AppxPackage-Name$Name

My difficulty is I'm not clear / can't find information on taking that and making it into a If-Then statement so that If the specific store app exists some action will then occur.

Any advice would be appreciated.


A+, Network+, Security+, Microsoft MCP, MCDST, MCSE 2003, MCSA 2008

Viewing all 21975 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>